Created
January 26, 2013 22:08
-
-
Save paulosman/4644946 to your computer and use it in GitHub Desktop.
Using the password auth flow with the PHP SDK
This file contains hidden or 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 'Services/Soundcloud.php'; | |
$client = new Services_Soundcloud('A_VALID_CLIENT_ID', 'A_VALID_CLIENT_SECRET', 'REDIRECT_URI'); | |
// manually construct URL-encoded request body. Note that if you use an email address | |
// as the username, you'll need to pass it through urlencode(). | |
$options = "grant_type=password&client_id=$CLIENT_ID&client_secret=$CLIENT_SECRET&username=<username>&password=<password>"; | |
// $response will be an object with four properties: access_token, refresh_token, expires_in and scope | |
$response = json_decode($client->post('oauth2/token', $options)); | |
// set the access token manually | |
$client->setAccessToken($response->access_token); | |
// ... | |
// $$$ | |
print_r(json_decode($client->get('me'))); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment