Advertisement
Guest User

Untitled

a guest
Aug 17th, 2016
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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.        }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement