开始使用Twitter API,并选择使用Twitterizer库与API进行接口。目前使用一个测试项目来做一些简单的任务,我遇到了一个问题,我似乎找不到任何信息在论坛或这里的堆栈。
设置
使用Twitterizer的
下面是抛出异常的代码片段:
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);最后一行将弹出一个空引用异常。
堆栈跟踪:
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)我已经看到了前面关于库中的Null引用异常的问题,但是这个问题出现在以前的版本(2.3.1)上。有人看到这个/知道一个参数或者我应该发送给这个函数/等等?我应该说,我已经顺利地使用了Timeline.Mentions和User.GetFollowers函数,因此这告诉我我的库配置是正确的.
发布于 2012-02-22 01:48:12
好的-我可能有,但我要先做一些测试。这个特定的函数有一个重载版本,RetweetsOfMeOptions作为第二个参数,在我的示例中,我没有使用这个版本。但是,如果我添加这一行代码:
var options = new RetweetsOfMeOptions {Count = 25, UseSSL = false};并更新我的函数调用以使用重载的调用:
TwitterResponse<TwitterStatusCollection> mentionsResponse = TwitterTimeline.RetweetsOfMe(oAuthToken, options);我没有明白这个错误。一旦我确定这是它-我将张贴到Twitterizer论坛/bug跟踪器作为一个潜在的问题。
https://stackoverflow.com/questions/9388048
复制相似问题