Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Soundcloud: The requested URL responded with HTTP code 0

I moved my code base from one server to another - no code change, the only difference being https. I modified my app in Soundcloud developers to be https://url , however I continuously receive this error:

[20-Sep-2013 15:08:35 Europe/London] PHP Fatal error:  Uncaught exception 'Services_Soundcloud_Invalid_Http_Response_Code_Exception' with message 'The requested URL responded with HTTP code 0.' in /system/soundcloud/Soundcloud.php:945
Stack trace:
#0 /soundcloud/Soundcloud.php(298): Soundcloud->_request('https://api.sou...', Array)
#1 /application/controllers/speaker/media.php(190): Soundcloud->credentialsFlow('soundcloud@...', '073ffbc3b66691c...')
#2 [internal function]: Media->add_audio()
#3 /system/core/CodeIgniter.php(359): call_user_func_array(Array, Array)
#4 /index.php(202): require_once('/home/iwantasp/...')
#5 {main}
  thrown in /system/soundcloud/Soundcloud.php on line 945

Again, this code worked perfectly on the previous server, it's merely server change.

We have implemented the security cert that is usually the cause for this problem to no avail (Soundcloud (Oauth2) API getting access token fails) - we're on a linux system anyways so shouldn't make a difference.

cURL also works on this server.

What else could cause my problem?

like image 579
rickyduck Avatar asked Feb 16 '23 05:02

rickyduck


2 Answers

It's hard to debug this exception without seeing the source code. But my guess is that your problem might be related to this issue:

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

Which means that you should modify your accessToken call and include the extra cURL parameters.

$accessToken = $soundcloud->accessToken($code, $postData, array(
    CURLOPT_SSL_VERIFYPEER => false,
    CURLOPT_SSL_VERIFYHOST => false,
));
like image 140
Cesar Canassa Avatar answered Feb 17 '23 18:02

Cesar Canassa


A much better solution would be to follow the answer listed on the following answer to Twitter API returns NULL on XAMPP which states that you should update the CA root certifications for your PHP solution.

For more information:

  • http://www.saotn.org/stop-turning-off-curlopt_ssl_verifypeer-and-fix-your-php-config/
  • http://snippets.webaware.com.au/howto/stop-turning-off-curlopt_ssl_verifypeer-and-fix-your-php-config/
like image 32
Malachi Avatar answered Feb 17 '23 18:02

Malachi