• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# TwitterService类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



TwitterService类属于命名空间,在下文中一共展示了TwitterService类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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_get_public_timeline

        public void Can_get_public_timeline()
        {
            var service = new TwitterService();
            var tweets = service.ListTweetsOnPublicTimeline();

            Assert.IsNotNull(tweets);
            Assert.AreEqual(20, tweets.Count());

            Assert.IsNotNull(service.Response);
            Assert.AreEqual(HttpStatusCode.OK, service.Response.StatusCode);
            
            var unfavorited = 20;
            foreach (var tweet in tweets)
            {
                Assert.IsNotNullOrEmpty(tweet.RawSource);
                Assert.AreNotEqual(default(DateTime), tweet.CreatedDate);

                Console.WriteLine("{0} said '{1}'", tweet.User.ScreenName, tweet.Text);
                if(tweet.IsFavorited)
                {
                    unfavorited--;
                }
            }

            Assert.IsTrue(unfavorited > 0);
            AssertRateLimitStatus(service);
        }
开发者ID:nadeemmar,项目名称:tweetsharp,代码行数:27,代码来源:TwitterServiceTests.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: OnNavigatedTo

 protected override async void OnNavigatedTo(NavigationEventArgs e)
 {
     if (e.Parameter is TwitterService)
     {
         TwitterClient = e.Parameter as TwitterService;
         List<Tweet> lists = await TwitterClient.requestTwitterApi(_getHomeTimelineUrl);
         foreach (Tweet tweet in lists)
         {
             ViewModel.tweets.Add(tweet);
         }
         List<Tweet> mentions = await TwitterClient.requestTwitterApi(_getMentionsUrl);
         foreach (Tweet tweet in mentions)
         {
             MentionsViewModel.tweets.Add(tweet);
         }
         List<Tweet> userstweets = await TwitterClient.requestTwitterApi(_getUserTimelineUrl);
         foreach (Tweet tweet in userstweets)
         {
             ProfileViewModel.tweets.Add(tweet);
         }
     }
     else
     {
         //no tweets
     }
     base.OnNavigatedTo(e);
 }
开发者ID:matdestr,项目名称:Twitter,代码行数:27,代码来源:HomePage.xaml.cs


示例5: Can_parse_ids_greater_than_53_bits

 public void Can_parse_ids_greater_than_53_bits()
 {
     const string json = "{ \"id\": 90071992547409921}";
     var status = new TwitterService().Deserialize<TwitterStatus>(json);
     Assert.IsNotNull(status);
     Assert.AreEqual(90071992547409921, status.Id);
 }
开发者ID:braahyan,项目名称:tweetsharp,代码行数:7,代码来源:TwitterServiceTests.cs


示例6: 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


示例7: 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


示例8: Can_get_request_token_async

				public async Task Can_get_request_token_async()
				{
					var service = new TwitterService(_consumerKey, _consumerSecret);
					var result = await service.GetRequestTokenAsync();
			
					Assert.AreEqual(result.Response.StatusCode, HttpStatusCode.OK);
					Assert.NotNull(result.Value);
				}
开发者ID:FrenchW,项目名称:tweetmoasharp,代码行数:8,代码来源:TwitterServiceTests.OAuth.cs


示例9: Can_get_request_token

 public void Can_get_request_token()
 {
     var service = new TwitterService(_consumerKey, _consumerSecret);
     var requestToken = service.GetRequestToken();
     
     AssertResultWas(service, HttpStatusCode.OK);
     Assert.NotNull(requestToken);
 }
开发者ID:PetroProts,项目名称:tweetsharp,代码行数:8,代码来源:TwitterServiceTests.OAuth.cs


示例10: 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


示例11: Authorize

        public ActionResult Authorize()
        {
            TwitterService service = new TwitterService(_consumerKey, _consumerSecret);
            OAuthRequestToken requestToken = service.GetRequestToken();

            var uri = service.GetAuthorizationUri(requestToken);
            return new RedirectResult(uri.ToString(), false /*permanent*/);
        }
开发者ID:nyxtom,项目名称:tweetsharp,代码行数:8,代码来源:HomeController.cs


示例12: GetTweets_Can_Successfully_Retrieve_Values_From_Twitter

        public void GetTweets_Can_Successfully_Retrieve_Values_From_Twitter()
        {
            var query = "#ltnet";
            var twitterService = new TwitterService();

            var tweets = twitterService.GetTweets(query, this.date);

            Assert.That(tweets.Count(), Is.GreaterThan(0));
        }
开发者ID:mmozuras,项目名称:DotNetGroup,代码行数:9,代码来源:TwitterServiceTests.cs


示例13: GetTweers_Returns_Empty_List_When_No_Results_Found

        public void GetTweers_Returns_Empty_List_When_No_Results_Found()
        {
            var empty = 0;
            var query = "#hashtagfortesting";
            var twitterService = new TwitterService();

            var tweets = twitterService.GetTweets(query, this.date);

            Assert.AreEqual(empty, tweets.Count());
        }
开发者ID:mmozuras,项目名称:DotNetGroup,代码行数:10,代码来源:TwitterServiceTests.cs


示例14: GetTweers_Returns_Empty_List_When_Internal_Exception_Happens

        public void GetTweers_Returns_Empty_List_When_Internal_Exception_Happens()
        {
            var empty = 0;
            string query = null;
            var twitterService = new TwitterService();

            var tweets = twitterService.GetTweets(query, this.date);

            Assert.AreEqual(empty, tweets.Count());
        }
开发者ID:mmozuras,项目名称:DotNetGroup,代码行数:10,代码来源:TwitterServiceTests.cs


示例15: GetTweetsOnHashTags

    public string GetTweetsOnHashTags(string hashTags)
    {
        var service = new TwitterService(consumerKey, consumerSecret);
        service.AuthenticateWith(accessToken, accessTokenSecret);
        SearchOptions so = new SearchOptions();
        so.Q = "#"+hashTags;

        so.Count = 100;
        var tweeting = service.Search(so);
        IEnumerable<TwitterStatus> returnValue = tweeting.Statuses;
        TweetsInst tweets = null;
        MulTweetInstance multweets = new MulTweetInstance();
        foreach (var twt in returnValue)
        {
            tweets = new TweetsInst();
            if (twt.Author.ScreenName != null)
            {
                tweets.author = twt.Author.ScreenName;
            }
            else { tweets.author = ""; }
            if (twt.Author.ProfileImageUrl != null)
            {
                tweets.UserImage = twt.Author.ProfileImageUrl;
            }
            else { tweets.UserImage = ""; }
            if (twt.User != null)
            {
                tweets.User_ID = Convert.ToString(twt.User.Id);
            }
            else { tweets.User_ID = null; }
            if (twt.Text != null)
            {
                tweets.tweet = twt.Text;
            }
            else { tweets.tweet = ""; }
            if (twt.Location != null)
            {
                tweets.latitude = Convert.ToString(twt.Location.Coordinates.Latitude);
            }
            else { tweets.latitude = ""; }
            if (twt.Location != null)
            {
                tweets.longitude = Convert.ToString(twt.Location.Coordinates.Longitude);
            }
            else { tweets.longitude = null; }
            if (twt.Place != null)
            {
                tweets.country = twt.Place.Country;
            }
            else { tweets.country = ""; }
                multweets.mulTweet.Add(tweets);
        }
        string output = JsonConvert.SerializeObject(multweets);
        return output;
    }
开发者ID:ksm5629,项目名称:WebServices,代码行数:55,代码来源:Service.cs


示例16: OAuthDialog

        public OAuthDialog(IAccessTokenStore accessTokenStore, ITwitterApplicationCredentials applicationCredentials)
        {
            _accessTokenStore = accessTokenStore;
            _applicationCredentials = applicationCredentials;
            InitializeComponent();

            pinTextBox.Visibility = Visibility.Hidden;
            pinLbl.Visibility = Visibility.Hidden;
            pinInstruction.Visibility = Visibility.Hidden;

            _service = new TwitterService(_applicationCredentials.ConsumerKey,
                                          _applicationCredentials.ConsumerSecret);
        }
开发者ID:GraemeF,项目名称:Twiddler,代码行数:13,代码来源:OAuthDialog.xaml.cs


示例17: Given_Last_Tweet_Date_GetTweets_Can_Successfully_Retrieve_Latest_Values_From_Twitter

        public void Given_Last_Tweet_Date_GetTweets_Can_Successfully_Retrieve_Latest_Values_From_Twitter()
        {
            var query = "#ltnet";
            var twitterService = new TwitterService();

            var tweets = twitterService.GetTweets(query, this.date).ToList();
            if (tweets.Count() > 1)
            {
                var fromDate = tweets.Last().Published;
                var latestTweets = twitterService.GetTweets(query, fromDate);

                Assert.That(tweets.Count(), Is.GreaterThan(latestTweets.Count()));
            }
        }
开发者ID:mmozuras,项目名称:DotNetGroup,代码行数:14,代码来源:TwitterServiceTests.cs


示例18: 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


示例19: TestSetup

        public void TestSetup()
        {
            var consumerKey = ConfigurationManager.AppSettings["consumerKey"];
            var consumerSecret = ConfigurationManager.AppSettings["consumerSecret"];

            if (string.IsNullOrEmpty(consumerKey))
                Assert.Inconclusive("You must set the consumer key for integration tests to run.");
            if (string.IsNullOrEmpty(consumerSecret))
                Assert.Inconclusive("You must set the consumer secret for integration tests to run.");

            var auth = new ApplicationOnlyAuth(consumerKey, consumerSecret);
            _sut = new TwitterService(auth);

        }
开发者ID:ryanlangton,项目名称:DEG.Shared.Twitter,代码行数:14,代码来源:TwitterServiceTests.cs


示例20: Can_initialize_generated_service

        public void Can_initialize_generated_service()
        {
            _username = ConfigurationManager.AppSettings["TwitterUsername"];
            _password = ConfigurationManager.AppSettings["TwitterPassword"];

            _consumerKey = ConfigurationManager.AppSettings["OAuthConsumerKey"];
            _consumerSecret = ConfigurationManager.AppSettings["OAuthConsumerSecret"];
            _token = ConfigurationManager.AppSettings["OAuthAccessToken"];
            _tokenSecret = ConfigurationManager.AppSettings["OAuthTokenSecret"];

            _service = new TwitterService(_consumerKey, _consumerSecret);
            
            var ignore = ConfigurationManager.AppSettings["IgnoreStatusUpdateTests"];
            if(!bool.TryParse(ignore, out _ignoreTestsThatPostToTwitter))
            {
                _ignoreTestsThatPostToTwitter = true;
            }
        }
开发者ID:BigBadChicago,项目名称:hammock,代码行数:18,代码来源:TwitterServiceTests.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Type类代码示例发布时间:2022-05-24
下一篇:
C# TwitterSearchResultType类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap