Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static void Main(string[] args)
- {
- //WebClient to communicate via http
- WebClient client = new WebClient();
- //Client id form SoundCloud
- string ClientId = "...";
- //Client secret id from SoundCloud
- string ClientSecret = "...";
- //Credentials (username & password)
- string username = "...";
- string password = "...";
- //Authentication data
- string postData = "client_id=" + ClientId
- + "&client_secret=" + ClientSecret
- + "&grant_type=password&username=" + username
- + "&password=" + password;
- //Authentication
- string soundCloudTokenRes = "https://api.soundcloud.com/oauth2/token";
- string tokenInfo = client.UploadString(soundCloudTokenRes, postData);
- //Parse the token
- tokenInfo = tokenInfo.Remove(0, tokenInfo.IndexOf("token\":\"") + 8);
- string token = tokenInfo.Remove(tokenInfo.IndexOf("\""));
- //SoundCloud API Get Request
- string soundCloudMeRes = "https://api.soundcloud.com/me.xml";
- string meData = client.DownloadString(soundCloudMeRes + "?oauth_token=" + token);
- //Print the Data
- Console.WriteLine(meData);
- Console.ReadKey(true);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement