【发布时间】:2020-01-16 11:11:46
【问题描述】:
我正在开始一个新的 c# 项目,我想在其中提取一些推文,目前没有具体内容,只是为了开始......
我在 Twitter API 上创建了一个开发者用户并创建了一个新应用程序并获得了所有的 consumerkey 和 accesstoken...
根据此链接 - https://github.com/JoeMayo/LinqToTwitter/wiki/Single-User-Authorization 一切都应该相当顺利,但我没有得到任何结果......
我的项目是一个 .net 控制台应用程序,这是我的代码,几乎是从我上面提到的参考资料中复制粘贴的:
var auth = new SingleUserAuthorizer
{
CredentialStore = new SingleUserInMemoryCredentialStore
{
ConsumerKey = ...,
ConsumerSecret = ...,
AccessToken = ...,
AccessTokenSecret = ...
}
};
var twitterCtx = new TwitterContext(auth);
var searchResponse =
(from search in twitterCtx.Search
where search.Type == SearchType.Search &&
search.Query == "\"LINQ to Twitter\""
select search)
.SingleOrDefault();
if (searchResponse != null && searchResponse.Statuses != null)
searchResponse.Statuses.ForEach(tweet =>
Console.WriteLine(
"User: {0}, Tweet: {1}",
tweet.User.ScreenNameResponse,
tweet.Text));
我什至不知道如何识别身份验证过程是否成功, 请问有什么帮助吗? 谢谢!
【问题讨论】:
标签: c# twitter linq-to-twitter