全部,
我在 Windows 控制台应用程序中有以下代码。我正在使用 LinqtoTwitter ( http://linqtotwitter.codeplex.com/ )。auth.IsAuthorized 行返回 true。但它在搜索时失败,并出现 Invalid/Expired token 错误。我已经检查并仔细检查了密钥和令牌。任何帮助将不胜感激。
static void processTweets()
{
var auth = new SingleUserAuthorizer
{
Credentials = new InMemoryCredentials
{
ConsumerKey = Utility.GetSetting("ConsumerKey"),
ConsumerSecret = Utility.GetSetting("ConsumerSecret"),
AccessToken = Utility.GetSetting("Accesstoken"),
OAuthToken = Utility.GetSetting("AccesstokenSecret")
}
};
auth.Authorize();
TwitterContext twitterCtx = new TwitterContext(auth);
if (auth == null || !auth.IsAuthorized)
{
}
var srch =
(from search in twitterCtx.Search
where search.Type == SearchType.Search &&
search.Query == "LINQ to Twitter" &&
search.Count == 7
select search)
.SingleOrDefault();
Console.WriteLine("\nQuery: {0}\n", srch.SearchMetaData.Query);
srch.Statuses.ForEach(entry =>
Console.WriteLine(
"ID: {0, -15}, Source: {1}\nContent: {2}\n",
entry.StatusID, entry.Source, entry.Text));
}