2012-02-22 76 views
0

开始玩弄Twitter API并选择使用Twitterizer库与API进行接口。目前使用测试项目来完成一些简单的任务,我遇到了一个问题,我似乎无法在论坛或堆栈中找到任何信息。Twitterizer对象参考未设置

的设置

  1. 使用Twitterizer版本2.4(的NuGet)
  2. 使用NewtonSoft JSON版本4.0.2(已经从4.0.8由于序列化问题在降级)
  3. .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); 

最后一行pukes了一个空参考异常

堆栈跟踪:

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)。任何人都遇到过/知道一个参数或我应该发送到这个函数/ etc?我应该说,我成功地使用了Timeline.Mentions和User.GetFollowers函数没有问题,所以这告诉我我的库配置有点正确...

回答

0

好吧 - 我可能有它,但要去做先测试一下。这个特殊的函数有一个重载的版本,其中RetweetsOfMeOptions作为第二个参数,在我的例子中,我没有使用这个版本。不过,如果我加入这行代码:

var options = new RetweetsOfMeOptions {Count = 25, UseSSL = false}; 

而且更新我的函数调用来使用重载的呼叫:

TwitterResponse<TwitterStatusCollection> mentionsResponse = TwitterTimeline.RetweetsOfMe(oAuthToken, options); 

我没有得到这个错误。一旦我确信这是它 - 我会发布到Twitterizer论坛/ bug跟踪器作为一个潜在的问题。