Пример #1
0
        public static void Main(string[] args)
        {
            RdioClient client = new RdioClient(RdioConsumerCredentials.Consumer);

            RdioClient.AuthState authState = client.BeginAuthentication("oob");
            Console.WriteLine("Visit {0}", authState.Url);
            Console.Write("Enter the PIN: ");
            string pin = Console.ReadLine();

            OAuth.Token accessToken;
            try {
                accessToken = client.CompleteAuthentication(pin, authState.RequestToken);
            } catch (RdioClient.AuthorizationException ex) {
                Console.WriteLine(ex);
                return;
            }
            client = new RdioClient(client.Consumer, accessToken);

            JObject response = JObject.Parse(client.Call("getPlaylists"));

            foreach (var playlist in response["result"]["owned"])
            {
                Console.WriteLine("{0}\t{1}", playlist["shortUrl"], playlist["name"]);
            }
        }
Пример #2
0
        // Uncomment this test to test the login and also to obtain the access token required
        // for the other tests.
        //[TestMethod]
        public void Authenticate()
        {
            var client = new RdioClient(ClientFactory.ConsumerKey, ClientFactory.ConsumerSecret);

            var response = client.RequestUserAuthorizationAsync().Result;

            Assert.IsNotNull(response.AuthorizationUrl);
            Assert.IsNotNull(response.RequestToken);
            Assert.IsTrue(response.CallbackConfirmed);
            Assert.AreEqual(OAuth.OAuthTokenType.Request, response.RequestToken.Type);
            Assert.IsNotNull(response.RequestToken.Token);
            Assert.IsNotNull(response.RequestToken.Secret);

            Process.Start(response.AuthorizationUrl.ToString()).WaitForExit();

            var verifier = Microsoft.VisualBasic.Interaction.InputBox("Fill the verification code.", "RdioNet", "", 0, 0);

            var token = client.CompleteUserAuthorizationAsync(verifier).Result;

            Assert.IsNotNull(token);
            Assert.AreEqual(OAuth.OAuthTokenType.Access, token.Type);
            Assert.IsNotNull(token.Token);
            Assert.IsNotNull(token.Secret);

            Microsoft.VisualBasic.Interaction.InputBox("", "RdioNet", "AccessToken = " + token.Token + "; AccessSecret = " + token.Secret, 0, 0);
        }
Пример #3
0
        public void TestClient01()
        {
            var consumerKey    = ConfigurationManager.AppSettings["consumerKey"];
            var consumerSecret = ConfigurationManager.AppSettings["consumerSecret"];
            var accessToken    = ConfigurationManager.AppSettings["accessToken"];
            var accessSecret   = ConfigurationManager.AppSettings["accessSecret"];
            var client         = new RdioClient(consumerKey, consumerSecret, accessToken, accessSecret);

            //var res = client.RequestUserAuthorizationAsync().Result;
            //////Process.Start(res.AuthorizationUrl.ToString()).WaitForExit();
            //string verifier = "";
            //var res2 = client.CompleteUserAuthorizationAsync(verifier).Result;
            var response   = client.Playback.GetPlaybackTokenAsync("asdlkj").Result;
            var playlists  = client.Playlists.GetPlaylistsAsync().Result;
            var myplaylist = playlists.Owned.First();
        }
Пример #4
0
 public PlaybackMethods(RdioClient client)
     : base(client)
 {
 }
Пример #5
0
        public void GetObjectFromShortCode()
        {
            var client = new RdioClient(ClientFactory.ConsumerKey, ClientFactory.ConsumerSecret, ClientFactory.AccessKey, ClientFactory.AccessSecret);

            var item = client.Core.GetObjectFromShortCodeAsync<RdioObject>("QitDAH7D").Result;

            Assert.IsNotNull(item);

            Exception exception = null;

            try
            {
                item = client.Core.GetObjectFromShortCodeAsync<RdioObject>("blablabla").Result;
            }
            catch (AggregateException ex)
            {
                exception = ex.Flatten().GetBaseException();
            }

            Assert.IsNotNull(exception);
        }
Пример #6
0
        public void GetObjectFromUrl()
        {
            var client = new RdioClient(ClientFactory.ConsumerKey, ClientFactory.ConsumerSecret, ClientFactory.AccessKey, ClientFactory.AccessSecret);

            var item = client.Core.GetObjectFromUrlAsync<RdioObject>("/artist/Crystal_Castles/album/(III)/").Result;

            Assert.IsNotNull(item);
        }
Пример #7
0
 public CollectionMethods(RdioClient client)
     : base(client)
 {
 }
Пример #8
0
 public PlaylistsMethods(RdioClient client)
     : base(client)
 {
 }
Пример #9
0
 public SocialNetworkMethods(RdioClient client)
     : base(client)
 {
 }