【问题标题】:PHP 5.4 Implementation of the Discogs APIPHP 5.4 Discogs API 的实现
【发布时间】:2015-03-12 03:20:29
【问题描述】:

在 Discogs API (https://github.com/ricbra/php-discogs-api) 的 PHP 5.4 实现中,有一个示例如何获取 $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 应用设置中给出。如何获取 token 和 token_secret?我尝试让这个示例代码在命令行中工作,但我主要得到一堆异常:

PHP 致命错误:未捕获的异常 带有消息“客户端错误”的“GuzzleHttp\Exception\ClientException” 回复 [网址] http://api.discogs.com/database/search?q=Metallica [状态码] 401 [原因短语] Unauthorized' in /var/www/darkplanet/vendors/composer/guzzlehttp/guzzle/src/Exception/RequestException.php:

【问题讨论】:

  • 通常是您的 OAuth 提供商提供的令牌和密码。您为 SSO 使用的是谁?例如,如果你可以使用 GitHub 登录,那么 GitHub 的管理面板就会有这些数据。
  • 看看Discogs developer documentation,它解释了如何以及在哪里获取令牌和令牌秘密。

标签: php oauth guzzle discogs-api


【解决方案1】:

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

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

【讨论】:

    猜你喜欢
    • 2014-02-21
    • 1970-01-01
    • 1970-01-01
    • 2013-07-01
    • 2019-01-05
    • 1970-01-01
    • 2015-05-23
    • 1970-01-01
    • 2015-07-11
    相关资源
    最近更新 更多