问题描述
我试图用PHP连接到的SoundCloud API OSX上我的本地MAMP服务器上。当我尝试连接/找回我得到的数据的URL回应HTTP code 0。客户端ID /秘密和重定向URI是正确的。这里是PHP code我使用 -
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?
推荐答案
我更新到服务器MAMP的最新版本解决了这一点。在MAMP更高版本中,他们列出,他们会加入支持SSL上的甲基苯丙胺亲 - 尽管我仍在使用MAMP的免费版本,那是我的提示,更新
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.
这篇关于如何使用PHP连接到的SoundCloud API,而HTTP错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!