SHOW:
|
|
- or go back to the newest paste.
| 1 | - | static void Main(string[] args) |
| 1 | + | static void Main(string[] args) |
| 2 | - | { |
| 2 | + | {
|
| 3 | - | //WebClient to communicate via http |
| 3 | + | //WebClient to communicate via http |
| 4 | - | WebClient client = new WebClient(); |
| 4 | + | WebClient client = new WebClient(); |
| 5 | - | |
| 5 | + | |
| 6 | - | //Client id form SoundCloud |
| 6 | + | //Client id form SoundCloud |
| 7 | - | string ClientId = "..."; |
| 7 | + | string ClientId = "..."; |
| 8 | - | |
| 8 | + | |
| 9 | - | //Client secret id from SoundCloud |
| 9 | + | //Client secret id from SoundCloud |
| 10 | - | string ClientSecret = "..."; |
| 10 | + | string ClientSecret = "..."; |
| 11 | - | |
| 11 | + | |
| 12 | - | //Credentials (username & password) |
| 12 | + | //Credentials (username & password) |
| 13 | - | string username = "..."; |
| 13 | + | string username = "..."; |
| 14 | - | string password = "..."; |
| 14 | + | string password = "..."; |
| 15 | - | |
| 15 | + | |
| 16 | - | //Authentication data |
| 16 | + | //Authentication data |
| 17 | - | string postData = "client_id=" + ClientId |
| 17 | + | string postData = "client_id=" + ClientId |
| 18 | - | + "&client_secret=" + ClientSecret |
| 18 | + | + "&client_secret=" + ClientSecret |
| 19 | - | + "&grant_type=password&username=" + username |
| 19 | + | + "&grant_type=password&username=" + username |
| 20 | - | + "&password=" + password; |
| 20 | + | + "&password=" + password; |
| 21 | - | |
| 21 | + | |
| 22 | - | //Authentication |
| 22 | + | //Authentication |
| 23 | - | string soundCloudTokenRes = "https://api.soundcloud.com/oauth2/token"; |
| 23 | + | string soundCloudTokenRes = "https://api.soundcloud.com/oauth2/token"; |
| 24 | - | string tokenInfo = client.UploadString(soundCloudTokenRes, postData); |
| 24 | + | string tokenInfo = client.UploadString(soundCloudTokenRes, postData); |
| 25 | - | |
| 25 | + | |
| 26 | - | //Parse the token |
| 26 | + | //Parse the token |
| 27 | - | tokenInfo = tokenInfo.Remove(0, tokenInfo.IndexOf("token\":\"") + 8); |
| 27 | + | tokenInfo = tokenInfo.Remove(0, tokenInfo.IndexOf("token\":\"") + 8);
|
| 28 | - | string token = tokenInfo.Remove(tokenInfo.IndexOf("\"")); |
| 28 | + | string token = tokenInfo.Remove(tokenInfo.IndexOf("\""));
|
| 29 | - | |
| 29 | + | |
| 30 | - | //SoundCloud API Get Request |
| 30 | + | //SoundCloud API Get Request |
| 31 | - | string soundCloudMeRes = "https://api.soundcloud.com/me.xml"; |
| 31 | + | string soundCloudMeRes = "https://api.soundcloud.com/me.xml"; |
| 32 | - | string meData = client.DownloadString(soundCloudMeRes + "?oauth_token=" + token); |
| 32 | + | string meData = client.DownloadString(soundCloudMeRes + "?oauth_token=" + token); |
| 33 | - | |
| 33 | + | |
| 34 | - | //Print the Data |
| 34 | + | //Print the Data |
| 35 | - | Console.WriteLine(meData); |
| 35 | + | Console.WriteLine(meData); |
| 36 | - | Console.ReadKey(true); |
| 36 | + | Console.ReadKey(true); |
| 37 | } |