1

我想在我的应用程序中使用 Twitter,我正在使用 Hammock Windows DLL 使用 Twitter,所以当我像这样创建其余客户端时

private void GetTwitterToken()
{
    var credentials = new OAuthCredentials
    {
        Type = OAuthType.RequestToken,
        SignatureMethod = OAuthSignatureMethod.HmacSha1,
        ParameterHandling = OAuthParameterHandling.HttpAuthorizationHeader,
        ConsumerKey = MyTwitter.ConsumerKey,
        ConsumerSecret = MyTwitter.ConsumerSecret,
        Version = MyTwitter.OAuthVersion,
        CallbackUrl = MyTwitter.CallbackUri
    };

    /*
    var client = new RestClient
    {
        Authority = "https://api.twitter.com/oauth",
        Credentials = credentials,
        HasElevatedPermissions = true
    };
    */

    var client = new RestClient
    {
        Authority = "https://api.twitter.com/oauth",
        Credentials = credentials,
        HasElevatedPermissions = true,
        SilverlightAcceptEncodingHeader = "gzip",
        DecompressionMethods = DecompressionMethods.GZip
    };

    var request = new RestRequest
    {
        Path = "/request_token"
    };
    client.BeginRequest(request, new RestCallback(TwitterRequestTokenCompleted));
}

private void TwitterRequestTokenCompleted(RestRequest request, RestResponse response, object userstate)
{
    Debug.WriteLine("Twitter Request Token Completed");

    _oAuthToken = GetQueryParameter(response.Content, "oauth_token");
    _oAuthTokenSecret = GetQueryParameter(response.Content, "oauth_token_secret");
    var authorizeUrl = MyTwitter.AuthorizeUri + "?oauth_token=" + _oAuthToken;

    if (String.IsNullOrEmpty(_oAuthToken) || String.IsNullOrEmpty(_oAuthTokenSecret))
    {
        Dispatcher.BeginInvoke(() => MessageBox.Show("error calling twitter"));
        return;
    }

    Dispatcher.BeginInvoke(() => browserControl.Navigate(new Uri(authorizeUrl)));
}

我收到 NullReferenceException-> Hammock.WindowsPhone.dll 错误!

Hammock.Silverlight.Compat.GzipHttpWebResponse.GetResponseStream() + 0x1c 字节

在堆栈中,我得到的错误是

在 Hammock.Silverlight.Compat.GzipHttpWebResponse.GetResponseStream()

在 Hammock.Web.WebQuery.GetAsyncResponseCallback(IAsyncResult asyncResult)

在 System.Net.Browser.ClientHttpWebRequest.<> c_DisplayClassa.<InvokeGetResponseCallback>b _8(对象状态 2)

在 System.Threading.ThreadPool.WorkItem.WaitCallback_Context(对象状态)

在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext,ContextCallback 回调,对象状态)

在 System.Threading.ThreadPool.WorkItem.doWork(对象 o)

在 System.Threading.Timer.ring()

可能是什么问题呢?

4

1 回答 1

0

有参考问题,是导致问题的原因,已修复,感谢您的支持乔恩

于 2012-05-23T13:48:58.343 回答