ricbra/discogs-bundle

基于Discogs API客户端的集合包

安装: 436

依赖项: 0

建议者: 8

安全: 0

星标: 9

关注者: 3

分支: 8

公开问题: 0

类型:symfony-bundle

1.0.1 2015-12-06 15:01 UTC

This package is not auto-updated.

Last update: 2024-09-14 13:04:53 UTC


README

Latest Stable Version Total Downloads Latest Unstable Version License

此包提供了将 "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'];