1
votes

In PHP 5.4 Implementation of the Discogs API (https://github.com/ricbra/php-discogs-api) there is example how to get $response = $client->search(['q' => 'Meagashira']); working with oauth1. The example states:

$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
]);

The consumer_key and consumet_secret is given in the discogs app setting. How do I get token and token_secret? I try to make this example code working from command line but I get bunch of exceptions mostly:

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:

1
Generally your token and secret from your OAuth provider. Who are you using for your SSO? For example if you can log on using GitHub, then GitHub's admin panel will have this data.halfer
Take a look at the Discogs developer documentation, it explains how and where to get the token and token secret.user2629998

1 Answers

1
votes

Disclaimer: I'm the author of the Discogs API PHP client.

Recently I've updated the README.md with a link to an example implementation which can be used as starting point. You can find this example implementation at: https://github.com/ricbra/php-discogs-api-example