定制 snapshotpl/last-fm-client 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

snapshotpl/last-fm-client

最新稳定版本:1.0

Composer 安装命令:

composer require snapshotpl/last-fm-client

包简介

README 文档

README

Modern Last.fm API client for php

Last.fm API documentation

Usage

You can call API methods using existing services:

<?php

require __DIR__ . '/vendor/autoload.php';

$auth = new LastFmClient\Auth();
$auth->setApiKey('your-api-key');
$auth->setSecret('your-secret');
$auth->setToken('user-token');
$auth->setSession('user-session');

$transport = new LastFmClient\Transport\Curl();

$client = new LastFmClient\Client($auth, $transport);

$trackService = new LastFmClient\Service\Track();
$trackService->setClient($client);

$response = $trackService->getInfo('Numb', 'Linkin Park');

var_dump($response->getData());

If you want to call custom method use LastFmClient\Client:

$client->call('resource.getAwesomeness', [], LastFmClient\Transport\TransportInterface::METHOD_GET);

How to scrobble?

It's very simple! Prepare LastFmClient\Auth object with api key, secret, token and session key. Then just call method from LastFmClient\Service\Track:

$trackService->scrobble('Seven Lions', 'Days to Come', $timestamp);

$timestamp is optional and can be integer with timestamp time or DateTime object.

You can scrobble multiple tracks in one request:

$trackService->scrobbleBatch([
    [
        'artist' => 'Linkin Park',
        'track' => 'Numb',
        'timestamp' => time()-1000,
    ],
    [
        'artist' => 'Seven Lions',
        'track' => 'Days to Come',
        'timestamp' => time()-1200,
    ],
]);

How to get Token and Session

You need to redirect user to auth page in Last.Fm:

$url = $client->getAuthUrl();
header('Location: '.$url);

In callback url you will receive query string parameter token.

$authService = LastFmClient\Service\Auth();
$authService->setClient($client);
$data = $authService->getSession()->getData();
var_dump($data);

More information:

Transport

To make calls in API we provide simple CURL transport. We have in plan implements others transports like:

  • Guzzle
  • Httpfull
  • Zend\Http

To use own transport just implement LastFmClient\Transport\TransportInterface

Installation

Add to composer.json:

{
    "require": {
        "snapshotpl/last-fm-client": "~1.0"
    }
}

统计信息

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

GitHub 信息

  • Stars: 2
  • Watchers: 3
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2015-01-06

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固