PHP 5.4 Implementation of the Discogs API

878 Views Asked by At

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

There are 1 best solutions below

0
On

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