声音云返回401错误 [英] Sound Cloud returning 401 error

查看:172
本文介绍了声音云返回401错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近我开始使用Sound cloud API(PHP),并决定使用PHP API。



https://github.com/mptre/php-soundcloud



但是当我试图通过此代码从Sound云服务器获取访问令牌时:

  //获取访问令牌
try {
$ accessToken = $ soundcloud-> accessToken(isset($ _ GET ['code']));
} catch(Services_Soundcloud_Invalid_Http_Response_Code_Exception $ e){
exit($ e-> getMessage());
}

在我的脚本中添加以下代码后,SC返回401错误



$ curlPath ='Fullpath\Of\cacert.crt';



$ curlSSLSertificate = str_replace(array ','\'),DIRECTORY_SEPARATOR,$ curlPath);



curl_setopt($ ch,CURLOPT_CAINFO,$ curlSSLSertificate);

我们添加了此代码以修复请求的URL响应HTTP代码0问题



,此后我们收到401错误。



有任何方法来解决这个问题。

解决方案

我认为

  $ accessToken = $ soundcloud-> accessToken(isset($ _ GET ['code'])); 

应读为

  $ accessToken = $ soundcloud-> accessToken($ _ GET ['code']); 


Recently I start work with Sound cloud API (PHP) and I decided to use PHP API by

https://github.com/mptre/php-soundcloud.

But When I am trying to get access token from Sound cloud server by this code:

// Get access token
try {
    $accessToken = $soundcloud->accessToken(isset($_GET['code']));
} catch (Services_Soundcloud_Invalid_Http_Response_Code_Exception $e) {
    exit($e->getMessage());
}

The SC returning 401 error after adding below code in my script

$curlPath = 'Fullpath\Of\cacert.crt';

$curlSSLSertificate = str_replace(array('/', '\'), DIRECTORY_SEPARATOR, $curlPath);

curl_setopt($ch, CURLOPT_CAINFO, $curlSSLSertificate);

We added this code to fix "The requested URL responded with HTTP code 0" issue

and after this we are getting 401 error.

Is there any way to fix this problem. If yes then Kindly, suggest me to look out there..

解决方案

I think

$accessToken = $soundcloud->accessToken(isset($_GET['code']));

should read

$accessToken = $soundcloud->accessToken($_GET['code']);

这篇关于声音云返回401错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆