问题
So I'm trying to get a playlist with SoundCloud API, but I'm getting a 401 when setting an access token.
<?PHP
require_once('Services/Soundcloud.php');
$client = new Services_Soundcloud('id', 'secret', 'uri');
if (!isset($_GET['code']))
{
header("Location: " . $client->getAuthorizeUrl());
}
$access_token = $client->accessToken($_GET['code']);
$client->setAccessToken($access_token);
?>
I think it may be a problem with me reusing the access token (maybe?). I'm not sure.
回答1:
For some reason it's broken again. I receive codes ending with hash (#
) which gets stripped when I try to get them with $_GET['code']
. Even when I manually append the hash the authentication still ends with 401, so I assume this is an internal error.
回答2:
Resolved it by simply adding posting "scope" with "non-expiring" and then using that code.
header("Location: " . $client->getAuthorizeUrl(array('scope' => 'non-expiring'));
来源:https://stackoverflow.com/questions/23031661/soundcloud-api-401