2017 © Pedro Peláez
 

library baelorphp

PHP Wrapper for baelor.io API

image

duffleman/baelorphp

PHP Wrapper for baelor.io API

  • Thursday, April 16, 2015
  • by Duffleman
  • Repository
  • 3 Watchers
  • 0 Stars
  • 3 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

baelorphp

php library for baelor.io., (*1)

Contents

Installation

$ composer install --no-dev -o, (*2)

Introduction

baelorphp is a php library for the baelor.io Taylor Swift API., (*3)

To obtain an API key for baelor.io, run the Create new API User example., (*4)

Quick Example

Let's load all of Taylor Swift's albums., (*5)

use Duffleman\baelor\BaelorAPI;

$api = new BaelorAPI('api-key');
$albumCollection = $api->getAlbums();

You can also wrap it around try/catch tags to see what (if any) errors are thrown., (*6)

Endpoints

Here is what we can do, also see the baelor.io docs for a full API endpoint list., (*7)

Create a user

use Duffleman\baelor\BaelorAPI;

$api = new BaelorAPI();
$user = $api->createUser('myUsername', 'myEmail', 'myPassword');

$ourNewAPIKey = $user->api_key;

Login as existing user

use Duffleman\baelor\BaelorAPI;

$api = new BaelorAPI();
$api->login('myUsername', 'myPassword');

$response = $api->getAlbums(); // Returns full set of Albums.

Get a single album

use Duffleman\baelor\BaelorAPI;

$api = new BaelorAPI('api-key');

$album = $api->getAlbums('1989');

Songs from that Album

Extending from the above example., (*8)

use Duffleman\baelor\BaelorAPI;

$api = new BaelorAPI('api-key');

$album = $api->getAlbums('1989');

$songs = $album->attributes;

All songs

use Duffleman\baelor\BaelorAPI;

$api = new BaelorAPI('api-key');

$songCollection = $api->getSongs();

Get a single song

use Duffleman\baelor\BaelorAPI;

$api = new BaelorAPI('api-key');

$song = $api->getSongs('style');

$length = $song->length; // We can access attributes directly.

Lyrics

Lyrics works slightly differently. But equally as easy., (*9)

use Duffleman\baelor\BaelorAPI;
use Duffleman\baelor\Results\Lyrics;

$api = new BaelorAPI('api-key');

$song = $api->getSongs('style');

$lyrics = new Lyrics($song, $api);

echo($lyrics->toHTML());

Bae Status

use Duffleman\baelor\BaelorAPI;

$api = new BaelorAPI('api-key');

$bae = $api->getBae('word');
// or
$bae = $api->getBae();

var_dump($bae);

Examples

Find the longest line in a song

use Duffleman\baelor\BaelorAPI;
use Duffleman\baelor\Results\Lyrics;

$api = new BaelorAPI('api-key');

$song = $api->getSongs('style');
$lyrics = new Lyrics($song, $api);

$lines = $lyrics->toArray(true); // true because we do want to strip empty lines.

$longestLength = 0;
$longestLine = '';
foreach($lines as $line) {
  $lineLength = strlen($line);
  if($lineLength > $longestLength) {
    $longestLength = $lineLength;
    $longestLine = $line;
  }
}

echo("The longest line is {$lineLength} characters long. It reads: {$longestLine}.");

Credits

Baelor API created by Alex Forbes-Reed @0xdeafcafe, (*10)

baelorjs libary created by Jamie Davies @viralpickaxe, (*11)

baelorphp libary created by George Miller @duffleman, (*12)

The Versions

16/04 2015

dev-master

9999999-dev

PHP Wrapper for baelor.io API

  Sources   Download

The Requires

 

The Development Requires

by George Miller

swift baelor

16/04 2015

2.0.0

2.0.0.0

PHP Wrapper for baelor.io API

  Sources   Download

The Requires

 

The Development Requires

by George Miller

swift baelor

14/04 2015

1.0.1

1.0.1.0

PHP Wrapper for baelor.io API

  Sources   Download

The Requires

 

The Development Requires

by George Miller

swift baelor

14/04 2015

1.0.0

1.0.0.0

PHP Wrapper for baelor.io API

  Sources   Download

The Requires

 

The Development Requires

by George Miller

swift baelor