使用地理代码计算趋势推文

时间:2014-01-20 19:57:42

标签: twitter tweetsharp

我正在努力寻找土耳其每个城市的热门推文。但“TwitterGeoLocationSearch”结果返回零。我正在使用TweetSharp 2.0和visual studio 2010。

请检查我的代码块。这里:

      private void btnTweetSearch_Click(object sender, EventArgs e)
    {
    service = new TwitterService("xxxx", "xxxxx", "xxxxxxx", "xxxxxxxx");

     var   CityGeoCode = new TwitterGeoLocationSearch(37.0000000, 35.3213330, 10, TwitterGeoLocationSearch.RadiusType.Km);

    var tweetss = service.Search(new SearchOptions { Q = " Turkey ", Count = 1000, Geocode = CityGeoCode });

            var TweetwithGeo = tweetss.Statuses.Where(x => x.Location != null );

          foreach (var tweet in TweetwithGeo)
            {

                    lbTweetWindow.Items.Add(tweet.Text);

                }

        } 

}

任何帮助,将非常感激。谢谢。

1 个答案:

答案 0 :(得分:0)

您的代码完美执行。 只需访问Twitter开发人员并获取您的consumerKey,consumerSecret,AccessToken,AccessTokenSecret

    private void btnTweetSearch_Click(object sender, EventArgs e) 
    {

            /* Your Authentication Code */
            var service = new TwitterService(_consumerKey, _consumerSecret);
            service.AuthenticateWith(_accessToken, _accessTokenSecret);

            /* Your Tweet Extracting code */
            var   CityGeoCode = new TwitterGeoLocationSearch(37.0000000, 35.3213330, 10, TwitterGeoLocationSearch.RadiusType.Km);

            var tweetss = service.Search(new SearchOptions { Q = " Turkey ", Count = 1000, Geocode = CityGeoCode });

            var TweetwithGeo = tweetss.Statuses.Where(x => x.Location != null );

            foreach (var tweet in TweetwithGeo)
            {

                lbTweetWindow.Items.Add(tweet.Text);
            }

     }