【问题标题】:Getting public tweets using C#使用 C# 获取公共推文
【发布时间】:2012-12-01 12:13:41
【问题描述】:
TwitterService service = new TwitterService();
service.AuthenticateWith("XXXXXX", "XXXXXXX");
// Geting Tweets On Specific Topic
var twts = service.Search("#ghaza", 100);
List<TwitterSearchStatus> resultList = new List<TwitterSearchStatus>(twts.Statuses);
foreach (var twt in resultList)
{
    Console.WriteLine(twt.Text);
}

我使用此代码获取有关 ghaza 的推文 有两件事我想知道

  1. 我应该怎么做才能得到json 表单中的结果
  2. 这在开始时给了我一些奇怪的输出 喜欢:
加入佳音 #伊朗 #伊拉克 #PAK #假 #GHAZA

经过一段时间的迭代,它会向我显示我想要以json 格式获取的推文

我用这个:

Console.WriteLine("{0} says '{1}'", twt.User.ScreenName, twt.Text);

但它不工作。

【问题讨论】:

  • 为什么要创建两个TwitterService 实例?并在第三个电话上调用AuthenticateWith
  • 我改了,但没有解决我的问题
  • 是哪个推特库?

标签: c# twitter tweetsharp twitter-client


【解决方案1】:

这对我有用

TwitterResponse<TwitterSearchResultCollection> tr = TwitterSearch.Search("#christmas");

TwitterSearchResultCollection results = tr.ResponseObject;
List<TwitterSearchResult> resultList = results.ToList();

foreach ( TwitterSearchResult resultRow in resultList ) {
    messages.AppendText( "\n" + resultRow.Text );
}

TwitterSearchResult 对象具有以下属性 (found in the documentation):

CreatedDate 

获取或设置创建日期。

FromUserId  

从用户 ID 获取或设置。

FromUserScreenName  

从用户屏幕获取或设置名称。

Geo 

获取或设置与结果关联的地理位置。

Id  

获取或设置状态id。

Language    

获取或设置语言。

Location    

获取或设置位置。

ProfileImageLocation    

获取或设置个人资料图片 URL。

Source  

获取或设置源。

Text    

获取或设置状态文本。

ToUserId    

获取或设置用户 ID。

ToUserScreenName    

获取或设置用户屏幕的名称。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-06-06
    • 2012-05-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-03-17
    • 2011-05-14
    • 1970-01-01
    相关资源
    最近更新 更多