问题是我不断收到401错误 $ client-> accessToken($ _ GET ['code'])步骤尽管正确设置了$ _GET ['code']。
require_once 'Services/Soundcloud.php';
// create client object with app credentials
define("CLIENT_ID","*****************");
define("CLIENT_SECRET","*****************");
define("REDIRECT_URL","********************");
$client = new Services_Soundcloud(CLIENT_ID, CLIENT_SECRET, REDIRECT_URL);
//redirect user to authorize URL
$authURL = $client->getAuthorizeUrl(array('scope'=>'non-expiring'));
$client->setDevelopment(false);
$code = $_GET['code'];
try {
if(!isset($_SESSION['token'])){
$code = $_GET['code'];
$access_token = $client->accessToken($code);
$_SESSION['token'] = $access_token['access_token'];
}else{
$client->setAccessToken($_SESSION['token']);
}
} catch (Services_Soundcloud_Invalid_Http_Response_Code_Exception $e) {
echo $e->getMessage();
}
获取The requested URL responded with HTTP code 401
非常感谢任何帮助。