daily pastebin goal
69%
SHARE
TWEET

SoundCloud Connect API

cansik May 14th, 2012 1,159 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
 
  1.         static void Main(string[] args)
  2.         {
  3.             //WebClient to communicate via http
  4.             WebClient client = new WebClient();
  5.  
  6.             //Client id form SoundCloud
  7.             string ClientId = "...";
  8.  
  9.             //Client secret id from SoundCloud
  10.             string ClientSecret = "...";
  11.  
  12.             //Credentials (username & password)
  13.             string username = "...";
  14.             string password = "...";
  15.  
  16.             //Authentication data
  17.             string postData = "client_id=" + ClientId
  18.                 + "&client_secret=" + ClientSecret
  19.                 + "&grant_type=password&username=" + username
  20.                 + "&password=" + password;
  21.            
  22.             //Authentication
  23.             string soundCloudTokenRes = "https://api.soundcloud.com/oauth2/token";
  24.             string tokenInfo = client.UploadString(soundCloudTokenRes, postData);
  25.            
  26.             //Parse the token
  27.             tokenInfo = tokenInfo.Remove(0, tokenInfo.IndexOf("token\":\"") + 8);
  28.             string token = tokenInfo.Remove(tokenInfo.IndexOf("\""));
  29.            
  30.             //SoundCloud API Get Request
  31.             string soundCloudMeRes = "https://api.soundcloud.com/me.xml";
  32.             string meData = client.DownloadString(soundCloudMeRes + "?oauth_token=" + token);
  33.  
  34.             //Print the Data
  35.             Console.WriteLine(meData);
  36.             Console.ReadKey(true);
  37.         }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top