开始使用 Twitter API 并选择使用 Twitterizer 库与 API 交互。目前正在使用一个测试项目来完成一些简单的任务,我遇到了一个问题,我似乎无法在论坛或堆栈上找到任何信息。
设置
- 使用 Twitterizer 版本 2.4 (NuGet)
- 使用 NewtonSoft JSON 版本 4.0.2(由于序列化问题不得不从 4.0.8 降级)
- .Net 4.0/MVC 项目
这是引发异常的代码片段:
var token = dbContext.TwitterProfiles.Where(x => x.TwitterId == MySuperSecretId).First();
var oAuthToken = new OAuthTokens
{
AccessToken = token.Token,
AccessTokenSecret = token.Secret,
ConsumerKey = ConfigurationManager.AppSettings["TwitterConsumerKey"],
ConsumerSecret = ConfigurationManager.AppSettings["TwitterConsumerSecret"]
};
TwitterResponse<TwitterStatusCollection> mentionsResponse = TwitterTimeline.RetweetsOfMe(oAuthToken);
最后一行吐出 Null Ref Exception
堆栈跟踪:
at Twitterizer.Commands.RetweetsOfMeCommand.Init()
at Twitterizer.Core.CommandPerformer.PerformAction[T](ICommand`1 command)
at Twitterizer.TwitterTimeline.RetweetsOfMe(OAuthTokens tokens, RetweetsOfMeOptions options)
at Twitterizer.TwitterTimeline.RetweetsOfMe(OAuthTokens tokens)
at TwitterTest.Controllers.HomeController.GetRetweets() in C:\Users\Tommy\Documents\Visual Studio 2010\Projects\TwitterTest\TwitterTest\Controllers\HomeController.cs:line 85
at lambda_method(Closure , ControllerBase , Object[] )
at System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters)
at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters)
at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters)
at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClass15.<InvokeActionMethodWithFilters>b__12()
at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation)
我已经看到了关于库中空引用异常的上一个问题,但该问题出现在以前的版本(2.3.1)上。有人遇到过这个/知道一个参数或我应该发送到这个函数/等的东西吗?我应该说我已经成功使用 Timeline.Mentions 和 User.GetFollowers 函数没有问题,所以这告诉我我的库配置有点正确......