REST Client + SoundCloud |
[eluser]austintbiggs[/eluser]
I'm trying to utilize the SoundCloud API using Phil Sturgeon's Rest Client which sits on the curl spark for those that haven't played with it. I'm currently able to load user information through the API using my Client ID, but as far as auth tokens I'm totally list on how to create or refresh them. I've taken a look at Ben Edmunds' Soundcloud library to try to grasp the concept, but the library uses OAuth1 instead of OAuth2 which SoundCloud is now pushing for everyone to use. SoundCloud Docs As I understand it my app needs to create a link Code: <a href="<?php echo $server.$authorize_url.'?client_id='.$client_id.'&response;_type='.$response_type.'&redirect;_uri='.$redirect_url;?>">Connect</a> and if the SoundCloud user authorizes my app then the user is redirected back to my app, while the url contains a query string Quote:http://yourapp.com/soundcloud/oauth-call...WsdhqVQr3g Then I need to be able to extract the "code" parameter of the url and use it in a curl call to Quote:https://api.soundcloud.com/oauth2/token Example Curl Code: $ curl "https://api.soundcloud.com/oauth2/token" Example returned from Curl Code: { Problems I'm facing: 1. How to get the "code" parameter from the returned url. 2. How to make the exchange for the tokens 3. What do I do with the token? Store it in a variable? A MySQL database? Other? 4. Is there a better way to load and utilize the API data? [see code below] My example controller : api.php Code: <?php My example view : index.php Code: <?php echo $soundcloud->id;?> As you can see I haven't made it very far as I'm stuck with the OAuth2 dance, any and all help is appreciated. Austin. |
Welcome Guest, Not a member yet? Register Sign In |