public Track GetTrack(String id) { if (storage.ClientCredentialsFlowAuthToken == null) { auth.GetClientCredentialsFlowAuthToken(); } var webClient = new WebClient(); JObject jObject = JObject.Parse(storage.ClientCredentialsFlowAuthToken); string AuthToken = (string)jObject.SelectToken("access_token"); //webClient.Headers.Add(HttpRequestHeader.Accept, "application/json"); webClient.Headers.Add(HttpRequestHeader.Authorization, "Bearer " + AuthToken); var GetResponse = SendClientCredentialsRequest(webClient, "https://api.spotify.com/v1/tracks/" + id); var jsonTrack = JObject.Parse(GetResponse); var trackId = jsonTrack["id"].ToString(); var songName = jsonTrack["name"].ToString(); var artistName = jsonTrack["artists"][0]["name"].ToString(); var image_small_url = jsonTrack["album"]["images"][2]["url"].ToString(); var image_medium_url = jsonTrack["album"]["images"][1]["url"].ToString(); var image_large_url = jsonTrack["album"]["images"][0]["url"].ToString(); var webplayerLink = jsonTrack["external_urls"]["spotify"].ToString(); Track track = new Track(trackId, songName, artistName, image_small_url, image_medium_url, image_large_url, webplayerLink); return(track); }
public void StartEvent() { // //Create tokens // storage.p8Token = p8.GetToken(); auth.GetRefreshAuthorizationCodeFlowAuthToken(); auth.GetClientCredentialsFlowAuthToken(); // // Create a timer with a two second interval. // //aTimer = new System.Timers.Timer(10000); // // Hook up the Elapsed event for the timer. // //aTimer.Elapsed += OnTimedEventAsync; // //aTimer.AutoReset = true; // //aTimer.Enabled = true; // //Console.WriteLine("\n\n\n\nTHE START EVENT TIMER WAS STARTED\n\n\n\n"); // //refreshTimer = new System.Timers.Timer(1800000); // ////To get token before 30 min. // //// Hook up the Elapsed event for the timer. // //refreshTimer.Elapsed += RefreshEventAsync; // //refreshTimer.AutoReset = true; // //refreshTimer.Enabled = true; }