public void Test_Groups_Delete_Add_Contribution() { var client = SoundCloudClient.CreateAuthorized(_settings.Token); var group = new Group(); group.id = GroupId; var track = new Track(); track.id = Track3Id; var result = client.Groups.Post(group, track); Assert.That(result.IsSuccess, Is.True); Assert.That(result.Data.id, Is.EqualTo(track.id)); var tracks = client.Groups.GetContributions(group); Assert.That(tracks.Any(x => x.id == track.id), Is.True); client.Groups.DeleteContribution(group, track); tracks = client.Groups.GetContributions(group); Assert.That(tracks.All(x => x.id != track.id), Is.True); }
static void Main(string[] args) { //fill credentials SoundCloudCredentials credentials = new SoundCloudCredentials(ClientId, ClientSecret, Username, Password); //create client SoundCloudClient client = new SoundCloudClient(credentials); //login to soundcloud SoundCloudAccessToken token = client.Authenticate(); //fetch some data if (client.IsAuthenticated) { //Fetch current user info var mySelf = User.Me(); //search for tracks string searchFor = "electro swing"; //execute search List <Track> searchResults = Track.Search(searchFor, null, Filter.All, "", "", null, null, null, null, DateTime.MinValue, DateTime.Now, null, null, null); //iterate in tracks and fetch details again foreach (int trackId in searchResults.Select(track => track.Id)) { Track track = Track.GetTrack(trackId); //here you can play a track or do something else ;) } } //wait for user input Console.ReadLine(); }
/// <summary> /// Initialize SoundCloud API with the provided ClientID. /// </summary> protected async Task init() { client = SoundCloudClient.CreateUnauthorized(clientId); var entity = await client.Resolve.GetEntityAsync("https://soundcloud.com/" + username); user = entity as User; }
public void Test_Playlists_Get() { var client = SoundCloudClient.CreateAuthorized(_settings.Token); var playlist = new Playlist(); playlist.title = "TestPlaylist"; playlist.tracks = new List <Track>(); playlist.tracks.Add(new Track { id = TrackId }); playlist.tag_list = new List <string> { "Sampletag", "Sampletag2" }; playlist.genre = "Sample"; playlist.playlist_type = PlaylistType.Compilation; var postResult = client.Playlists.Post(playlist); Assert.IsTrue(postResult.IsSuccess); var requestPlaylist = client.Playlists.Get(postResult.Data.id); client.Playlists.Delete(postResult.Data); Assert.That(requestPlaylist, Is.Not.Null); Assert.That(requestPlaylist.tracks.Count, Is.GreaterThanOrEqualTo(1)); Assert.That(requestPlaylist.uri.Query, Does.Contain("oauth_token=" + _settings.Token)); Assert.That(requestPlaylist.created_with.uri.Query, Does.Contain("oauth_token=" + _settings.Token)); Assert.That(requestPlaylist.tracks[0].uri.Query, Does.Contain("oauth_token=" + _settings.Token)); Assert.That(requestPlaylist.user.uri.Query, Does.Contain("oauth_token=" + _settings.Token)); }
public void Test_Playlists_GetSecretToken() { var client = SoundCloudClient.CreateAuthorized(_settings.Token); var playlist = new Playlist(); playlist.title = "TestPlaylist"; playlist.tracks = new List <Track>(); playlist.tracks.Add(new Track { id = TrackId }); playlist.tag_list = new List <string> { "Sampletag", "Sampletag2" }; playlist.genre = "Sample"; playlist.playlist_type = PlaylistType.Compilation; var postResult = client.Playlists.Post(playlist); Assert.IsTrue(postResult.IsSuccess); var token = client.Playlists.GetSecretToken(postResult.Data); client.Playlists.Delete(postResult.Data); Assert.That(string.IsNullOrWhiteSpace(token.token), Is.False); }
public async Task OAuth2_RefreshToken() { var client = SoundCloudClient.CreateUnauthorized(Settings.ClientId); var loginCredentials = new Credentials(); loginCredentials.ClientId = Settings.ClientId; loginCredentials.ClientSecret = Settings.ClientSecret; loginCredentials.Username = Settings.Username; loginCredentials.Password = Settings.Password; var loginResult = await client.OAuth2.LoginAsync(loginCredentials); Assert.That(loginResult.AccessToken, Is.Not.Empty); var credentials = new Credentials(); credentials.ClientId = Settings.ClientId; credentials.ClientSecret = Settings.ClientSecret; credentials.RefreshToken = loginResult.RefreshToken; var refreshResult = await client.OAuth2.RefreshTokenAsync(credentials); Assert.That(refreshResult.AccessToken, Is.Not.Empty); Assert.That(refreshResult.RefreshToken, Is.Not.Empty); Assert.That(refreshResult.ExpiresIn, Is.Not.Null); }
public async Task Me_Follow_Unfollow() { const int userId = 66852985; var client = SoundCloudClient.CreateAuthorized(Settings.Token); var user = new User { Id = userId }; var followResult = await client.Me.FollowAsync(user); Assert.That(followResult.Errors, Is.Empty); var followingsResult1 = await client.Me.GetFollowingsAsync(); Assert.That(followingsResult1, Has.One.Matches <User>(x => x.Id == user.Id)); var unfollowResult = await client.Me.UnfollowAsync(user); Assert.That(unfollowResult.Errors, Is.Empty); var followingsResult2 = await client.Me.GetFollowingsAsync(); Assert.That(followingsResult2, Has.None.Matches <User>(x => x.Id == user.Id)); }
public void Test_Me_WebProfile_Post_Delete() { var client = SoundCloudClient.CreateAuthorized(_settings.Token); var profile = new WebProfile(); profile.url = "http://facebook.com"; profile.title = "Facebook"; profile.service = WebService.Facebook; var postResult = client.Me.PostWebProfile(profile); Assert.That(postResult.IsSuccess, Is.True); Assert.That(postResult.Data.url, Is.EqualTo(profile.url)); Assert.That(postResult.Data.title, Is.EqualTo(profile.title)); var profiles = client.Me.GetWebProfiles(); Assert.That(profiles.Any(x => x.id == postResult.Data.id), Is.True); var deleteResult = client.Me.DeleteWebProfile(postResult.Data); Assert.That(deleteResult.IsSuccess, Is.True); profiles = client.Me.GetWebProfiles(); Assert.That(profiles.All(x => x.id != postResult.Data.id), Is.True); }
public void Test_OAuth2_RefreshToken() { var client = SoundCloudClient.Create(); var loginCredentials = new Credentials(); loginCredentials.client_id = _settings.ClientId; loginCredentials.client_secret = _settings.ClientSecret; loginCredentials.username = _settings.Username; loginCredentials.password = _settings.Password; var loginResult = client.OAuth2.Login(loginCredentials); Assert.That(loginResult.IsSuccess, Is.True); var credentials = new Credentials(); credentials.client_id = _settings.ClientId; credentials.client_secret = _settings.ClientSecret; credentials.refresh_token = loginResult.Data.refresh_token; var refreshResult = client.OAuth2.RefreshToken(credentials); Assert.That(refreshResult.IsSuccess, Is.True); Assert.That(string.IsNullOrEmpty(refreshResult.Data.access_token), Is.False); Assert.That(string.IsNullOrEmpty(refreshResult.Data.refresh_token), Is.False); Assert.That(refreshResult.Data.expires_in, Is.Not.Null); }
public Plugin(IApplicationPaths applicationPaths, IXmlSerializer xmlSerializer, IEncryptionManager encryption) : base(applicationPaths, xmlSerializer) { Instance = this; _encryption = encryption; var username = Instance.Configuration.Username; var password = Instance.Configuration.PwData; var creds = new SoundCloudCredentials("78fd88dde7ebf8fdcad08106f6d56ab6", "ef6b3dbe724eff1d03298c2e787a69bd"); if (username != null && password != null) { creds = new SoundCloudCredentials("78fd88dde7ebf8fdcad08106f6d56ab6", "ef6b3dbe724eff1d03298c2e787a69bd", username, _encryption.DecryptString(Instance.Configuration.PwData)); } _SoundCloudClient = new SoundCloudClient(creds); if (username != null && password != null) { _SoundCloudClient.Authenticate(); } }
public async Task Me_WebProfile_Post_Delete() { var client = SoundCloudClient.CreateAuthorized(Settings.Token); var profile = new WebProfile { Url = "http://facebook.com", Title = "Facebook", Service = WebService.Facebook }; var postResult = await client.Me.PostWebProfileAsync(profile); Assert.That(postResult.Url, Is.EqualTo(profile.Url)); Assert.That(postResult.Title, Is.EqualTo(profile.Title)); var profilesResult1 = await client.Me.GetWebProfilesAsync(); Assert.That(profilesResult1, Has.One.Matches <Track>(x => x.Id == postResult.Id)); var deleteResult = await client.Me.DeleteWebProfileAsync(postResult); Assert.That(deleteResult.Error, Is.Null.Or.Empty); Assert.That(deleteResult.Errors, Is.Empty); var profilesResult2 = await client.Me.GetWebProfilesAsync(); Assert.That(profilesResult2, Has.None.Matches <Track>(x => x.Id == postResult.Id)); }
public async Task Me_Like_Unlike() { const int trackId = 211433527; var client = SoundCloudClient.CreateAuthorized(Settings.Token); var track = new Track { Id = trackId }; var likeResult = await client.Me.LikeAsync(track); Assert.That(likeResult.Errors, Is.Empty); var favoritesResult1 = await client.Me.GetFavoritesAsync(); Assert.That(favoritesResult1, Has.One.Matches <Track>(x => x.Id == track.Id)); var unlikeResult = await client.Me.UnlikeAsync(track); Assert.That(unlikeResult.Errors, Is.Empty); var favoritesResult2 = await client.Me.GetFavoritesAsync(); Assert.That(favoritesResult2, Has.None.Matches <Track>(x => x.Id == track.Id)); }
public async Task Playlists_GetSecretToken() { var client = SoundCloudClient.CreateAuthorized(Settings.Token); var playlist = new Playlist(); playlist.Title = "TestPlaylist"; playlist.Tracks = new List <Track> { new Track { Id = TrackId } }; playlist.TagList = new List <string> { "Sampletag", "Sampletag2" }; playlist.Genre = "Sample"; playlist.PlaylistType = PlaylistType.Compilation; var postResult = await client.Playlists.PostAsync(playlist); Assert.That(postResult.Title, Is.EqualTo(playlist.Title)); var token = await client.Playlists.GetSecretTokenAsync(postResult); Assert.That(token.Token, Is.Not.Empty); var deleteResult = await client.Playlists.DeleteAsync(postResult); Assert.That(deleteResult.Error, Is.Null.Or.Empty); Assert.That(deleteResult.Errors, Is.Empty); }
public void Test_Me_GetConnections() { var client = SoundCloudClient.CreateAuthorized(_settings.Token); var connections = client.Me.GetConnections().ToList(); Assert.That(connections.Any(), Is.True); }
public void Test_Me_GetActivity() { var client = SoundCloudClient.CreateAuthorized(_settings.Token); var activities = client.Me.GetActivities().Take(100).ToList(); Assert.That(activities.Any(), Is.True); }
public void Test_Apps() { var client = SoundCloudClient.CreateUnauthorized(ClientId); var apps = client.Apps; Assert.That(apps, Is.Not.Null); }
public void Test_Playlist() { var client = SoundCloudClient.CreateUnauthorized(ClientId); var playlists = client.Playlists; Assert.That(playlists, Is.Not.Null); }
public void Test_Me_GetPlaylists() { var client = SoundCloudClient.CreateAuthorized(_settings.Token); var playlists = client.Me.GetPlaylists().ToList(); Assert.That(playlists.Any(), Is.True); }
public void Test_Me_GetFollowings() { var client = SoundCloudClient.CreateAuthorized(_settings.Token); var followings = client.Me.GetFollowings(); Assert.That(followings.Any(), Is.True); }
public void Resolve_GetUrl_Wrong_Url() { var client = SoundCloudClient.CreateUnauthorized(Settings.ClientId); var exception = Assert.ThrowsAsync <SoundCloudApiException>(async() => await client.Resolve.GetEntityAsync("https://soundcloud.com/sharpsound-12345")); Assert.That(exception.HttpStatusCode, Is.EqualTo(HttpStatusCode.NotFound)); }
public void Test_User() { var client = SoundCloudClient.CreateUnauthorized(ClientId); var user = client.Users; Assert.That(user, Is.Not.Null); }
public void Test_Track() { var client = SoundCloudClient.CreateUnauthorized(ClientId); var tracks = client.Tracks; Assert.That(tracks, Is.Not.Null); }
public void Test_Resolve() { var client = SoundCloudClient.CreateUnauthorized(ClientId); var resolve = client.Resolve; Assert.That(resolve, Is.Not.Null); }
public void Test_Me() { var client = SoundCloudClient.CreateUnauthorized(ClientId); var me = client.Me; Assert.That(me, Is.Not.Null); }
public SoundCloud(string username, string clientid) { this.username = username; client = SoundCloudClient.CreateUnauthorized(clientid); var entity = client.Resolve.GetEntityAsync("https://soundcloud.com/" + username).GetAwaiter().GetResult(); user = entity as User; }
public void Test_OAuth() { var client = SoundCloudClient.CreateUnauthorized(ClientId); var oAuth2 = client.OAuth2; Assert.That(oAuth2, Is.Not.Null); }
public void Test_Me_GetWebProfiles() { var client = SoundCloudClient.CreateAuthorized(_settings.Token); var groups = client.Me.GetWebProfiles().ToList(); Assert.That(groups.Any(), Is.True); }
public void Test_Comments() { var client = SoundCloudClient.CreateUnauthorized(ClientId); var comments = client.Comments; Assert.That(comments, Is.Not.Null); }
public void Test_Me_GetTracks() { var client = SoundCloudClient.CreateAuthorized(_settings.Token); var tracks = client.Me.GetTracks(); Assert.That(tracks.Any(), Is.True); }
public void Test_Resolve_GetUrl_Wrong_Url() { var client = SoundCloudClient.CreateUnauthorized(_settings.ClientId); var result = client.Resolve.GetEntity("https://soundcloud.com/sharpsound-12345"); Assert.That(result, Is.Null); }
protected void Page_Load(object sender, EventArgs e) { SoundCloudClient sc = new SoundCloudClient ("b7cd21ffd93dc601e76f180705b84429", "8425feac820870f86617c8607608c30e", "http://test.trackprotect.com/Social/scconnect.aspx", false); if (string.IsNullOrEmpty(Request.QueryString["code"])) { Response.Redirect(sc.GetAuthorizeUrl()); } else { sc.GetAccessToken(Request.QueryString["code"]); } }
//protected void Page_Load(object sender, EventArgs e) protected void tbGo_Click(object sender, EventArgs e) { // TODO: 2012-02-14 Emiya : Перенести в Page_Load object obj = Session[Settings.SoundCloudClientSessionKey]; if (obj == null) { string consumer_key = ConfigurationManager.AppSettings["consumerKey"]; string consumer_secret = ConfigurationManager.AppSettings["consumerSecret"]; string redirectUri = ConfigurationManager.AppSettings["redirectUri"]; const bool isDebug = false; // TODO: 2012-02-14 Emiya : после отладки удалить var client = new SoundCloudClient(consumer_key, consumer_secret, redirectUri, isDebug); string authorizeUrl = client.GetAuthorizeUrl(); Session[Settings.SoundCloudClientSessionKey] = client; Response.Redirect(authorizeUrl, true); } Session[Settings.SoundCloudClientSessionKey] = obj; Response.Redirect("~/callback.aspx", true); }
protected override void AdditionalSetup() { SoundCloudClient = new SoundCloudClient(ClientId); }