承接 duffleman/baelorphp 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

duffleman/baelorphp

最新稳定版本:2.0.0

Composer 安装命令:

composer require duffleman/baelorphp

包简介

PHP Wrapper for baelor.io API

README 文档

README

php library for baelor.io.

Contents

Installation

$ composer install --no-dev -o

Introduction

baelorphp is a php library for the baelor.io Taylor Swift API.

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

Quick Example

Let's load all of Taylor Swift's albums.

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.

Endpoints

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

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.

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.

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

baelorjs libary created by Jamie Davies @viralpickaxe

baelorphp libary created by George Miller @duffleman

统计信息

  • 总下载量: 13
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 4
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2015-04-14

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固