我正在尝试在特定位置发送推文。我正在使用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部分,我可以得到结果。但我希望在特定的位置半径获得推文。
答案 0 :(得分:0)
我设法使用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();
}
}
}