Created
November 26, 2012 08:44
-
-
Save mgng/4147236 to your computer and use it in GitHub Desktop.
soundcloud API で認証
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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