Skip to content

Instantly share code, notes, and snippets.

@mgng mgng/result.txt
Created Nov 26, 2012

Embed
What would you like to do?
soundcloud API で認証
stdClass Object
(
[id] => 3163465
[kind] => user
[permalink] => mgng
[username] => mgng
[uri] => https://api.soundcloud.com/users/3163465
[permalink_url] => http://soundcloud.com/mgng
[avatar_url] => https://i1.sndcdn.com/avatars-000013936604-9iswyu-large.jpg?afed582
[country] => Japan
[full_name] => mg ng
[description] => guitar, delay, kaossilator
[city] =>
[discogs_name] =>
[myspace_name] =>
[website] => http://mgng.aws.af.cm/
[website_title] => mgng
[online] => 1
[track_count] => 13
[playlist_count] => 1
[public_favorites_count] => 8
[followers_count] => 4
[followings_count] => 6
[plan] => Free
[private_tracks_count] => 0
[private_playlists_count] => 0
[primary_email_confirmed] => 1
)
<?php
require_once '/path/to/php-soundcloud-master/Services/Soundcloud.php';
$soundcloud = new Services_Soundcloud(
'YOUR_CLIENT_ID',
'YOUR_CLIENT_SECRET',
'YOUR_REDIRECT_URI'
);
$soundcloud->setCurlOptions( array(
// via. http://curl.haxx.se/ca/cacert.pem
CURLOPT_CAINFO => '/path/to/cacert.pem'
) );
// 認証URLへリダイレクト
if ( ! isset( $_GET['code'] ) ) {
header( 'Location: ' . $soundcloud->getAuthorizeUrl() );
exit();
}
try {
// access_token を設定
$accessTokenList = $soundcloud->accessToken( $_GET['code'] );
$soundcloud->setAccessToken( $accessTokenList['access_token'] );
// ログインしてる人の情報を取得
$me = json_decode( $soundcloud->get('me') );
print_r( $me );
} catch (Services_Soundcloud_Invalid_Http_Response_Code_Exception $e) {
echo $e->getMessage();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.