【问题标题】:Get Tweets Within Specific Location with TweetSharp使用 TweetSharp 在特定位置获取推文
【发布时间】:2016-08-09 01:31:26
【问题描述】:

我正在尝试在特定位置获取推文。我为此使用 TweetSharp。我尝试了以下代码:

// Pass your credentials to the service
            TwitterService service = new TwitterService("xx", "xx");


            // Step 4 - User authenticates using the Access Token
            service.AuthenticateWith("xx-xx", "xx");

            TwitterGeoLocationSearch geoSearch = new TwitterGeoLocationSearch(39.56, 32.52, 500, TwitterGeoLocationSearch.RadiusType.Km);

            //IEnumerable<TwitterStatus> mentions = service.ListTweetsOnHomeTimeline(new ListTweetsOnHomeTimelineOptions());

            var tweets = service.Search(new SearchOptions() { Q = "ankara", Count = 30, Geocode = geoSearch });

但 tweets.Statuses 返回空。如果我从 SearchOptions 中删除 Geocode 部分,我可以获得结果。但我想在特定位置半径内获取推文。

【问题讨论】:

  • service.Response 是否显示状态代码、原因短语或内容正文中的任何错误详细信息?

标签: c# asp.net twitter tweetsharp


【解决方案1】:

我设法用 Twitterizer 库做到了:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            var tokens = new Twitterizer.OAuthTokens
            {
                ConsumerKey = @"",
                ConsumerSecret = @"",
                AccessToken = @"-",
                AccessTokenSecret = @""
            };

            var response = Twitterizer.TwitterSearch.Search(tokens, " ",
              new Twitterizer.SearchOptions
              {
                  Count = 5,
                  GeoCode = "39.920687,32.853970,50km"
              });
            if (response.Result != Twitterizer.RequestResult.Success)
                return;
            var index = 0;
            foreach (var status in response.ResponseObject)
            {
                index++;
                Console.WriteLine(index);
                Console.WriteLine(status.Text);
                Console.WriteLine(status.CreatedDate);


            }

            Console.ReadLine();
        }
    }
}

【讨论】:

    猜你喜欢
    • 2016-05-18
    • 2016-03-15
    • 1970-01-01
    • 1970-01-01
    • 2021-02-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-12-12
    相关资源
    最近更新 更多