2015-01-14 40 views
1

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

$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_secret?我尽量让这个示例代码的命令行工作,但我得到异常大多是一串:

PHP Fatal error: Uncaught exception 'GuzzleHttp\Exception\ClientException' with message 'Client error response [url] http://api.discogs.com/database/search?q=Metallica [status code] 401 [reason phrase] Unauthorized' in /var/www/darkplanet/vendors/composer/guzzlehttp/guzzle/src/Exception/RequestException.php:

+0

通常来自您的OAuth提供者的令牌和秘密。你在为SSO使用谁?例如,如果您可以使用GitHub登录,那么GitHub的管理面板将拥有此数据。 – halfer

+0

查看[Discogs开发者文档](http://www.discogs.com/developers/#page:authentication),它解释了如何以及在何处获取令牌和令牌密钥。 –

回答