简体   繁体   English

Soundcloud API 401

[英]Soundcloud API 401

So I'm trying to get a playlist with SoundCloud API, but I'm getting a 401 when setting an access token. 因此,我尝试使用SoundCloud API获取播放列表,但设置访问令牌时却收到401。

<?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. 我不确定。

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'] . 我收到以哈希( # )结尾的代码,当我尝试使用$_GET['code']获取$_GET['code']时,该代码将被剥离。 Even when I manually append the hash the authentication still ends with 401, so I assume this is an internal error. 即使当我手动附加哈希时,身份验证仍以401结尾,因此我认为这是内部错误。

通过简单地添加带有“未过期”的发布“作用域”,然后使用该代码来解决该问题。

header("Location: " . $client->getAuthorizeUrl(array('scope' => 'non-expiring'));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM