I'm attempting to connect to discogs.com api with Zend_Oauth as part of a custom Magento module.
Discogs API details are here:
I've followed details for using Zend Oauth here: introduction
Suggested code is as follows...
(I've set up a test account on Discogs so the Key and Secret here are correct and live and can be tested.)
$config = array(
'callbackUrl' => 'http://www.example-discogs-app.co.uk',
'siteUrl' => 'http://api.discogs.com/oauth',
'consumerKey' => 'qvJGTkWsbVMGZGYCHCrQ',
'consumerSecret' => 'iBMnIrhFzoHjqaiVbkhhrmipzcaBwBCc'
);
$consumer = new Zend_Oauth_Consumer($config);
// fetch a request token
$token = $consumer->getRequestToken();
// persist the token to storage
$_SESSION['DISCOGS_REQUEST_TOKEN'] = serialize($token);
// redirect the user
$consumer->redirect();
I get a request token and get redirected to: api.discogs.com/oauth/authorize?oauth_token=xyzrequesttoken
With this displayed:
"{"message": "The requested resource was not found."}"
NB: When I run the same code against Twitter API Oauth with the relevant account key details it works and redirects to twitter for access confirmation as it should.
I've tried various $config settings with no luck, eg requestScheme, requestMethod,.
I figured it could be something to do with required headers so I've also tried replacing $consumer->redirect(); with the following... ($token being extracted from the $token response above)
$client = new Zend_Http_Client();
$client->setHeaders('Content-Type: application/json');
$client->setHeaders('User-Agent: +Xyz');
$client->setUri('http://api.discogs.com/oauth/authorize?oauth_token='.$token);
$client->setMethod(Zend_Http_Client::POST);
$response = $client->request();
I get the same response:
"{"message": "The requested resource was not found."}"
Any help would be much appreciated.
The kind people at discogs pointed out that the authorize url should be www not api so the correct config that works looks like this:
$config = array(
'callbackUrl' => http://www.example-discogs-app.co.uk,
'consumerKey' => 'tJOGhRhfsCQKnGCaOZin',
'consumerSecret' => 'dxyrhywgvMgVqrZsmncCrQyAXnRHwZVq',
'requestTokenUrl' => 'http://api.discogs.com/oauth/request_token',
'authorizeUrl' => 'http://www.discogs.com/oauth/authorize',
'accessTokenUrl' => 'http://api.discogs.com/oauth/access_token',
);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.