Joe
Joe

Reputation: 457

How to connect to Soundcloud API with PHP without HTTP error

I'm trying to connect to the soundcloud API with PHP on my local MAMP server on OSX. When I try to connect/retrieve the data I get 'The URL responded with HTTP code 0'. The client ID/secret and redirect URI are all correct. Here is the PHP code I am using-

<?php

require 'Soundcloud.php';

$soundcloud = new Services_Soundcloud('ID','Secret', 'http://localhost:8888/connect.php');


$authorizeURL = $soundcloud->getAuthorizeUrl();

echo "<a href='$authorizeURL'>Connect with SoundCloud</a>";

try {
$accessToken = $soundcloud->accessToken($_GET['code']);
print_r($accessToken);
} 
catch (Services_Soundcloud_Invalid_Http_Response_Code_Exception $e) {
exit($e->getMessage());
}



try {
$me = json_decode($soundcloud->get('me'), true);
print_r($me);
}
catch (Services_Soundcloud_Invalid_Http_Response_Code_Exception $e) {
exit($e->getMessage());
}

Does anyone have any idea on this?

Upvotes: 0

Views: 1227

Answers (1)

Joe
Joe

Reputation: 457

I solved this by updating to the newest version of MAMP server. In later versions of MAMP they listed that they'd added support for SSL on MAMP pro - and although I am still using the free version of MAMP, that was my cue to update.

Upvotes: 1

Related Questions