首页 文章

PHP 5.4 Discogs API的实现

提问于
浏览
1

在PHP 5.4 Discogs API的实现(https://github.com/ricbra/php-discogs-api)中,有一个例子如何获得$ response = $ client-> search(['q' => 'Meagashira']);与oauth1合作 . 该示例说明:

$oauth = new GuzzleHttp\Subscriber\Oauth\Oauth1([
    'consumer_key'    => $consumerKey, // from Discogs developer page
    'consumer_secret' => $consumerSecret, // from Discogs developer page
    'token'           => $token['oauth_token'], // get this using a OAuth library
    'token_secret'    => $token['oauth_token_secret'] // get this using a OAuth library
]);

consumer_key和consumet_secret在discogs app设置中给出 . 我如何获得令牌和token_secret?我尝试从命令行使这个示例代码工作,但我主要得到一堆例外:

PHP致命错误:未捕获异常'GuzzleHttp \ Exception \ ClientException',消息'客户端错误响应[url] http://api.discogs.com/database/search?q=Metallica [状态代码] 401 [原因短语]未经授权'in /var/www/darkplanet/vendors/composer/guzzlehttp/guzzle/src/Exception/RequestException.php:

1 回答

  • 1

    免责声明:我是Discogs API PHP客户端的作者 .

    最近我更新了README.md,其中包含一个可用作起点的示例实现的链接 . 您可以在以下位置找到此示例实现:https://github.com/ricbra/php-discogs-api-example

相关问题