ricbra / discogs-bundle
基于Discogs API客户端的集合包
1.0.1
2015-12-06 15:01 UTC
Requires
- ricbra/php-discogs-api: ^1.0
Suggests
- hwi/oauth-bundle: Enable OAuth support using HWIOAuthBundle
This package is not auto-updated.
Last update: 2024-09-14 13:04:53 UTC
README
此包提供了将 "Discogs库" 简单集成到Symfony2中的功能。您可以在http://www.discogs.com/developers/index.html上的专门页面找到有关此库的更多信息。
<?php $discogs = $this->container->get('discogs');
该包提供了一个新的discogs
服务,该服务返回一个Discogs\Service
的实例。
安装
$ composer require ricbra/discogs-bundle ~1.0.0
启用包
在内核中启用包
<?php // app/AppKernel.php public function registerBundles() { $bundles = array( // ... new Ricbra\Bundle\DiscogsBundle\RicbraDiscogsBundle(), ); }
配置
启用或禁用限速
ricbra_discogs:
throttle:
enabled: false # or true
要启用OAuth,您还需要使用一些第三方库来进行连接和授权。此包提供了对HWIOAuthBundle的支持。token_provider_id
是提供令牌和令牌密钥的服务ID。您在Discogs认证后可以获得此ID。
ricbra_discogs:
oauth:
enabled: true
consumer_key: _get_this_from_discogs_
consumer_secret: _get_this_from_discogs_
token_provider_id: ricbra_discogs.hwi_oauth_token_provider
基本用法
您只需从容器中请求discogs
服务,获取Discogs\Service
的实例,并开始发出API调用即可。
<?php $discogs = $this->container->get('discogs'); $artist = $discogs->getArtist([ 'id' => 120 ]); echo $artist['name'];