当前位置: 首页>>代码示例>>C#>>正文


C# TwitterService.AuthenticateWith方法代码示例

本文整理汇总了C#中TwitterService.AuthenticateWith方法的典型用法代码示例。如果您正苦于以下问题:C# TwitterService.AuthenticateWith方法的具体用法?C# TwitterService.AuthenticateWith怎么用?C# TwitterService.AuthenticateWith使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TwitterService的用法示例。


在下文中一共展示了TwitterService.AuthenticateWith方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AuthorizeCallback

        public ActionResult AuthorizeCallback(string oauth_token, string oauth_verifier)
        {
            TwitterService service = new TwitterService(_consumerKey, _consumerSecret);
            var requestToken = new OAuthRequestToken {Token = oauth_token};

            OAuthAccessToken accessToken = service.GetAccessToken(requestToken, oauth_verifier);

            service.AuthenticateWith(accessToken.Token, accessToken.TokenSecret);
            TwitterUser user = service.VerifyCredentials();
            ViewModel.Message = string.Format("Your username is {0}", user.ScreenName);

            return View("Index");
        }
开发者ID:nyxtom,项目名称:tweetsharp,代码行数:13,代码来源:HomeController.cs

示例2: Can_tweet_with_protected_resource_info

 public void Can_tweet_with_protected_resource_info()
 {
     var service = new TwitterService(_consumerKey, _consumerSecret);
     service.AuthenticateWith(_accessToken, _accessTokenSecret);
     var status = service.SendTweet(new SendTweetOptions { Status = DateTime.Now.Ticks.ToString() });
     Assert.IsNotNull(status);
 }
开发者ID:PetroProts,项目名称:tweetsharp,代码行数:7,代码来源:TwitterServiceTests.OAuth.cs

示例3: Can_get_media_links_from_entities

        public void Can_get_media_links_from_entities()
        {
            var service = new TwitterService(_consumerKey, _consumerSecret);
            service.AuthenticateWith(_accessToken, _accessTokenSecret);

            var tweet = service.GetTweet(128818112387756032);
            Assert.IsNotNull(tweet.Entities);
            Assert.AreEqual(1, tweet.Entities.Media.Count);

            var media = tweet.Entities.Media[0];
            Assert.AreEqual("http://p.twimg.com/AcmnZAXCMAEaDD1.jpg", media.MediaUrl);
            Assert.AreEqual("https://p.twimg.com/AcmnZAXCMAEaDD1.jpg", media.MediaUrlHttps);
            Assert.AreEqual("http://twitter.com/sarah_hatton/status/128818112387756032/photo/1", media.ExpandedUrl);
            Assert.AreEqual("pic.twitter.com/xCdS2Emt", media.DisplayUrl);
            Assert.AreEqual(TwitterMediaType.Photo, media.MediaType);
            Assert.AreEqual(69, media.Indices[0]);
            Assert.AreEqual(89, media.Indices[1]);
            Assert.AreEqual("128818112391950337", media.IdAsString);
            Assert.AreEqual(128818112391950337, media.Id);

            // Sizes
            Assert.AreEqual(4, media.Sizes.Count());
            Assert.AreEqual("fit", media.Sizes.Large.Resize);
            Assert.AreEqual(597, media.Sizes.Large.Height);
            Assert.AreEqual(800, media.Sizes.Large.Width);
        }
开发者ID:slodge,项目名称:tweetsharp,代码行数:26,代码来源:TwitterServiceTests.Client.cs

示例4: Can_get_reverse_geocode

        public void Can_get_reverse_geocode()
        {
            var service = new TwitterService(_consumerKey, _consumerSecret);
            service.AuthenticateWith(_accessToken, _accessTokenSecret);

            var places = service.ReverseGeocode(45.42153, -75.697193).ToList();
            Assert.IsNotEmpty(places);
            Assert.AreEqual(4, places.Count);

            places = places.OrderBy(p => p.Id).ToList();
            
            Assert.AreEqual("Ottawa, Ontario", places[0].FullName);
            Assert.AreEqual(TwitterPlaceType.City, places[0].PlaceType);
            Assert.AreEqual("06183ca2a30a18e8", places[0].Id);
            Assert.AreEqual(1, places[0].ContainedWithin.Count());
            Assert.AreEqual("89b2eb8b2b9847f7", places[0].ContainedWithin.ToList()[0].Id);
            
            Assert.AreEqual("Canada", places[1].FullName);
            Assert.AreEqual("3376992a082d67c7", places[1].Id);
            Assert.AreEqual(TwitterPlaceType.Country, places[1].PlaceType);

            Assert.AreEqual("Ontario, Canada", places[2].FullName);
            Assert.AreEqual(TwitterPlaceType.Admin, places[2].PlaceType);

            Assert.AreEqual("Québec, Canada", places[3].FullName);
            Assert.AreEqual(TwitterPlaceType.Admin, places[3].PlaceType);
        }
开发者ID:slodge,项目名称:tweetsharp,代码行数:27,代码来源:TwitterServiceTests.Client.cs

示例5: Can_support_secure_urls_in_entitities

        public void Can_support_secure_urls_in_entitities()
        {
            var service = new TwitterService(_consumerKey, _consumerSecret);
            service.AuthenticateWith(_accessToken, _accessTokenSecret);

            var tweet = service.GetTweet(131501393033961472);
            Console.WriteLine(tweet.RawSource);
        }
开发者ID:slodge,项目名称:tweetsharp,代码行数:8,代码来源:TwitterServiceTests.Client.cs

示例6: Can_get_basic_place

        public void Can_get_basic_place()
        {
            var service = new TwitterService(_consumerKey, _consumerSecret);
            service.AuthenticateWith(_accessToken, _accessTokenSecret);

            // Presidio
            var place = service.GetPlace("df51dec6f4ee2b2c");
            Assert.IsNotNull(place);
            Assert.AreEqual("df51dec6f4ee2b2c", place.Id);
            Assert.AreEqual("Presidio", place.Name);
            Assert.AreEqual("United States", place.Country);
            Assert.AreEqual("US", place.CountryCode);
            Assert.AreEqual("Presidio, San Francisco", place.FullName);
        }
开发者ID:slodge,项目名称:tweetsharp,代码行数:14,代码来源:TwitterServiceTests.Client.cs

示例7: Can_get_direct_messages

        public void Can_get_direct_messages()
        {
            var service = new TwitterService(_consumerKey, _consumerSecret);
            service.AuthenticateWith(_accessToken, _accessTokenSecret);
            var dms = service.ListDirectMessagesReceived();

            Assert.IsNotNull(dms);
            Assert.IsTrue(dms.Count() <= 20);

            Assert.IsNotNull(service.Response);
            AssertResultWas(service, HttpStatusCode.OK);

            foreach (var tweet in dms)
            {
                Assert.IsNotNull(tweet.RawSource);
                Assert.AreNotEqual(default(DateTime), tweet.CreatedDate);

                Console.WriteLine("{0} said '{1}'", tweet.SenderScreenName, tweet.Text);
            }

            AssertRateLimitStatus(service);
        }
开发者ID:nadeemmar,项目名称:tweetsharp,代码行数:22,代码来源:TwitterServiceTests.cs

示例8: Can_make_protected_resource_request_with_access_token

        public void Can_make_protected_resource_request_with_access_token()
        {
            var service = new TwitterService(_consumerKey, _consumerSecret);
            var request = service.GetRequestToken();

            AssertResultWas(service, HttpStatusCode.OK);
            Assert.NotNull(request);

            var uri = service.GetAuthorizationUri(request);
            Process.Start(uri.ToString());

            Console.WriteLine("Press the any key when you have confirmation of your code transmission.");
            var verifier = "1234567"; // <-- Debugger breakpoint and edit with the actual verifier

            var access = service.GetAccessToken(request, verifier);
            AssertResultWas(service, HttpStatusCode.OK);
            Assert.IsNotNull(access);

            service.AuthenticateWith(access.Token, access.TokenSecret);
            var mentions = service.ListTweetsMentioningMe(new ListTweetsMentioningMeOptions());
            Assert.IsNotNull(mentions);
            Assert.AreEqual(20, mentions.Count());
        }
开发者ID:PetroProts,项目名称:tweetsharp,代码行数:23,代码来源:TwitterServiceTests.OAuth.cs

示例9: Can_get_friends_or_followers_with_next_cursor

        public void Can_get_friends_or_followers_with_next_cursor()
        {
            var service = new TwitterService(_consumerKey, _consumerSecret);
            service.AuthenticateWith(_accessToken, _accessTokenSecret);

            var followers = service.ListFollowers(new ListFollowersOptions { ScreenName = _hero });
            Assert.IsNotNull(followers);
            Assert.IsNotNull(followers.NextCursor);
            Assert.IsNotNull(followers.PreviousCursor);
        }
开发者ID:braahyan,项目名称:tweetsharp,代码行数:10,代码来源:TwitterServiceTests.cs

示例10: GetAuthenticatedService

				private TwitterService GetAuthenticatedService(JsonSerializer serializer)
				{
					var service = new TwitterService(_consumerKey, _consumerSecret);
					if (serializer != null)
					{
						service.Serializer = serializer;
						service.Deserializer = serializer;
					}

					service.TraceEnabled = true;
					service.AuthenticateWith(_accessToken, _accessTokenSecret);
					return service;
				}
开发者ID:PetroProts,项目名称:tweetsharp,代码行数:13,代码来源:TwitterServiceTests.cs

示例11: Can_send_direct_message

 public void Can_send_direct_message()
 {
     var service = new TwitterService { IncludeEntities = true };
     service.AuthenticateWith(_consumerKey, _consumerSecret, _accessToken, _accessTokenSecret);
     var response = service.SendDirectMessage(new SendDirectMessageOptions
     {
         ScreenName = _hero,
         Text = "Test a tweetsharp dm " + DateTime.Now.Ticks
     });
     
     AssertResultWas(service, HttpStatusCode.OK);
     Assert.IsNotNull(response);
     Assert.IsFalse(response.Id == 0);
 }
开发者ID:PetroProts,项目名称:tweetsharp,代码行数:14,代码来源:TwitterServiceTests.cs

示例12: Can_get_geo_coordinates_from_specific_tweet

        public void Can_get_geo_coordinates_from_specific_tweet()
        {
            var service = new TwitterService(_consumerKey, _consumerSecret);
            service.AuthenticateWith(_accessToken, _accessTokenSecret);

            /*
             "geo": {
                    "type": "Point",
                    "coordinates": [
                        46.01364037,
                        -81.40501187
                    ]
                }, 
             */

            var last = service.GetTweet(new GetTweetOptions { Id = 133314374797492224 });
            Assert.IsNotNull(last.Place);
            Assert.IsNotNull(last.Location);
            Assert.AreEqual("Point", last.Location.Type);
            Assert.AreEqual(46.01364037, last.Location.Coordinates.Latitude);
            Assert.AreEqual(-81.40501187, last.Location.Coordinates.Longitude);
        }
开发者ID:Gordon-Beeming,项目名称:tweetsharp,代码行数:22,代码来源:TwitterServiceTests.Client.cs

示例13: Can_search_geo_by_lat_long

        public void Can_search_geo_by_lat_long()
        {
            var service = new TwitterService(_consumerKey, _consumerSecret);
            service.AuthenticateWith(_accessToken, _accessTokenSecret);

            var places = service.GeoSearch(new GeoSearchOptions { Lat = 45.42153, Long = -75.697193}).ToList();
            Assert.IsNotEmpty(places);

            places = places.OrderBy(p => p.Id).ToList();
            Assert.AreEqual("06183ca2a30a18e8", places[0].Id);
        }
开发者ID:Gordon-Beeming,项目名称:tweetsharp,代码行数:11,代码来源:TwitterServiceTests.Client.cs

示例14: Can_return_results_from_account_settings_endpoint

        public void Can_return_results_from_account_settings_endpoint()
        {
            //{"protected":false,
            //"geo_enabled":false,
            //"trend_location":[{"countryCode":"CA","name":"Canada","country":"Canada","placeType":{"name":"Country","code":12},"woeid":23424775,"url":"http:\/\/where.yahooapis.com\/v1\/place\/23424775","parentid":1}],
            //"language":"en",
            //"sleep_time":{"start_time":0,"end_time":12,"enabled":true},
            //"always_use_https":false,
            //"screen_name":"danielcrenna",
            //"show_all_inline_media":false,
            //"time_zone":{"name":"Eastern Time (US & Canada)","utc_offset":-18000,"tzinfo_name":"America\/New_York"},
            //"discoverable_by_email":true}

            var service = new TwitterService(_consumerKey, _consumerSecret);
            service.AuthenticateWith(_accessToken, _accessTokenSecret);

            var account = service.GetAccountSettings();
            Console.WriteLine(account.RawSource);

            Assert.AreEqual(false, account.IsProtected);
            Assert.AreEqual(true, account.GeoEnabled);
            Assert.IsNotNull(account.TrendLocations);
            Assert.AreEqual(1, account.TrendLocations.Count());
            Assert.AreEqual("CA", account.TrendLocations.Single().CountryCode);
            Assert.AreEqual("Canada", account.TrendLocations.Single().Name);
            Assert.AreEqual("Canada", account.TrendLocations.Single().Country);
            Assert.AreEqual("en", account.Language);
            Assert.AreEqual("danielcrenna", account.ScreenName);
            Assert.AreEqual(true, account.ShowAllInlineMedia);
            Assert.IsNotNull(account.TimeZone);
            Assert.AreEqual("Eastern Time (US & Canada)", account.TimeZone.Name);
            Assert.AreEqual(-18000, account.TimeZone.UtcOffset);
            Assert.AreEqual("America/New_York", account.TimeZone.InfoName);
            Assert.IsNotNull(account.SleepTime);
            Assert.AreEqual(0, account.SleepTime.StartTime, "start_time");
            Assert.AreEqual(12, account.SleepTime.EndTime, "end_time");
            Assert.AreEqual(true, account.SleepTime.Enabled);
        }
开发者ID:slodge,项目名称:tweetsharp,代码行数:38,代码来源:TwitterServiceTests.Client.cs

示例15: Can_search_geo_by_ip

        public void Can_search_geo_by_ip()
        {
            var service = new TwitterService(_consumerKey, _consumerSecret);
            service.AuthenticateWith(_accessToken, _accessTokenSecret);

            var places = service.GeoSearch(new GeoSearchOptions { Ip = "24.246.1.165" }).ToList();
            Assert.IsNotEmpty(places);

            places = places.OrderBy(p => p.Id).ToList();
            Assert.AreEqual("06183ca2a30a18e8", places[0].Id);
        }
开发者ID:Gordon-Beeming,项目名称:tweetsharp,代码行数:11,代码来源:TwitterServiceTests.Client.cs


注:本文中的TwitterService.AuthenticateWith方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。