2015-01-14 36 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),它解釋瞭如何以及在何處獲取令牌和令牌密鑰。 –

回答