Test whit php-soundcloud
I try to use the script php-soundcloud (Oauth 2) and I encounter a problem after user login.
I do exactly the tutorial wiki: https://github.com/mptre/php-soundcloud/wiki/Oauth-2
When the user has accepted the application, it returns the following URL: http://mywebsite.com/?code=123456789123456789
I get the correct $_GET['code']
but the function accessToken()
will not retrieve the information, it gives me a HTTP code 401 error (see the picture below).
Here is my code (the most basic):
<?php
include 'Services/Soundcloud.php';
$soundcloud = new Services_Soundcloud('_myClientId_', '_ClientSecret_', '_RedirectUri_');
echo '<a href="' . $soundcloud->getAuthorizeUrl() . '">Connect with SoundCloud</a><br />';
try {
$accessToken = $soundcloud2->accessToken($_GET['code']);
} catch (Services_Soundcloud_Invalid_Http_Response_Code_Exception $e) {
exit($e->getMessage());
}
Here is HTTP Status Codes of soundcloud: http://developers.soundcloud.com/docs/api/guide#errors
They say that the code 401 is: Make sure you're sending us a client_id
or access_token
.
But I'm sure to send the correct id and token! :/
If someone has already manipulate SoundCloud API and know why I get this error, let me know of any solution.