定制 sourceout/lastfm-php-sdk 二次开发

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

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

sourceout/lastfm-php-sdk

Composer 安装命令:

composer require sourceout/lastfm-php-sdk

包简介

LastFM SDK for PHP

README 文档

README

Latest Version Software License Build Status Code Coverage Scrutinizer Code Quality

This repository contains library the allows you to access Last.fm platform from your PHP application.

For details into how authenticate and obtain API Keys read Getting Started under API Introduction

Read the official API Documents at https://www.last.fm/api/intro for more information.

Features

Undermentioned is a list of feature this library provides:

  • Support for custom implementations (providers)
  • Choice of library used to for sending HTTP Requests
  • Framework Agnostic
  • Flexible & easy to extend

Installation

You can install this package via composer using this command:

composer require php-http/guzzle6-adapter guzzlehttp/psr7 php-http/message sourceout/lastfm-php-sdk

Although, the default installation instruction recommends Guzzle Http client it is not the only client that can be used. Refer the following list php-http/client-implementation for choices of clients.

For more information on this approach refer this documentation.

Usage

use Sourceout\LastFm\ProviderInterface;
use Sourceout\LastFm\Client as LastFmClient;
use Sourceout\LastFm\Provider\LastFm\LastFm;

/** @var ProviderInterface $provider */
$provider = new LastFm(['api_key' => 'your_api_key_here']);

/** @var LastFmClient $lastFmClient */
$lastFmClient = new LastFmClient();

/** @var Collection $topArtists */
$topArtists = $lastFmClient
    ->getServiceFactory($provider)
    ->getGeoService()
    ->getTopArtists(
        'united states',    // location
        1,                  // page number
        50                  // results per page
    );

You can also register your own custom provider instead of using the default, for e.g.

use Sourceout\LastFm\Client as LastFmClient;

$lastFmClient = new LastFmClient();

$lastFmClient->registerCustomProviders(
    [
        \path\to\custom\provider::class
        ...
        ...
    ]
);

Additionally, although the package features auto-discovery of http package/client, you can also set your own Http Client as well, below are examples where you provide Guzzle6 instance.

Method 1

use Sourceout\LastFm\Http\Http;
use Sourceout\LastFm\Http\HttpInterface;
use Sourceout\LastFm\Client as LastFmClient;
use Http\Adapter\Guzzle6\Client as GuzzleClient;
use Http\Message\MessageFactory\GuzzleMessageFactory;

/** @var HttpInterface $http */
$http = new Http();

$http->setHttpClient(new GuzzleClient());
$http->setMessageFactory(new GuzzleMessageFactory());

/** @var LastFmClient $lastFmClient */
$lastFmClient = new LastFmClient($http);

Method 2

use Sourceout\LastFm\Http\Http;
use Sourceout\LastFm\Http\HttpInterface;
use Sourceout\LastFm\Client as LastFmClient;
use Http\Adapter\Guzzle6\Client as GuzzleClient;
use Http\Message\MessageFactory\GuzzleMessageFactory;

/** @var HttpInterface $http */
$http = new Http();

$http->setHttpClient(new GuzzleClient());
$http->setMessageFactory(new GuzzleMessageFactory());

/** @var LastFmClient $lastFmClient */
$lastFmClient = new LastFmClient();
$lastFmClient->setHttpClient($http);

Supported Methods

There is a long list of API(s) provided by LastFm (ref.: https://www.last.fm/api), undermentioned is the list of methods currently supported by this library:

Geo
Geo.getTopArtists Get the most popular artists on Last.fm by country
Geo.getTopTracks Get the most popular tracks on Last.fm last week by country

Tests

You can run the tests with:

vendor/bin/phpunit

Contributing

Please see CONTRIBUTING for details.

Security

In case, you discover any security related issues, please email pulkit.swarup@gmail.com instead of using the issue tracker.

License

Please see License File for more information.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-07-02

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固