初始化时需要设置clientID
,clientSecret
和参数。redirectURI
new Services_Soundcloud
您的代码应如下所示:
index.php
<?php
// create client object with app credentials
include('Services/Soundcloud.php');
$client = new Services_Soundcloud('....', '....', 'http://my.redirect.com/url.php');
$authorizeUrl = $client->getAuthorizeUrl();
?>
<a href="<?php echo $authorizeUrl; ?>">Connect with SoundCloud</a>
和重定向网址:
<?php
require_once('Services/Soundcloud.php');
// create client object with app credentials
$client = new Services_Soundcloud('.....', '.....', 'http://my.redirect.com/url.php');
try {
$accessToken = $client->accessToken($_GET['code']);
try {
$me = json_decode($client->get('me'), true);
var_dump($me);
} catch (Services_Soundcloud_Invalid_Http_Response_Code_Exception $e) {
var_dump($e->getMessage());
exit();
}
} catch (Services_Soundcloud_Invalid_Http_Response_Code_Exception $e) {
var_dump($e->getMessage());
exit();
}
?>
您可以从开发人员页面clientId
获取andclientSecret
您还可以查看文档以获取 PHP、Python、Ruby 和 JS 中的正确示例
您可以在此链接上查看上面的代码:
soundcloud.itnews-bg.com/