1

我不能再在 TwitterService 中使用 GetRequestToken

还有GetAccessToken!

TwitterService service = new TwitterService("ConsumerKey", "ConsumerKeySecret");    
service.GetRequestToken(Constants.CallbackUri, (request, response) =>
            {
                if (response.StatusCode == HttpStatusCode.OK)
                {
                    Request = request;
                    var uri = service.GetAuthorizationUri(request);
                    Dispatcher.BeginInvoke(() => AuthBrowser.Navigate(uri));
                }

            });

它给了我:

“TweetSharp.TwitterService”不包含“GetRequestToken”的定义,并且找不到接受“TweetSharp.TwitterService”类型的第一个参数的扩展方法“GetRequestToken”(您是否缺少 using 指令或程序集引用?)

4

2 回答 2

2

我通过 Hammock ( https://github.com/danielcrenna/hammock )获取请求令牌来解决它

这是代码

 /// <summary>
    /// Gets Twitter Request Token 
    /// </summary>
    private void GetTwitterToken()
    {
        var credentials = new OAuthCredentials
        {
            Type = OAuthType.RequestToken,
            SignatureMethod = OAuthSignatureMethod.HmacSha1,
            ParameterHandling = OAuthParameterHandling.HttpAuthorizationHeader,
            ConsumerKey = "Your Consumer Key",
            ConsumerSecret = "Your Consumer Secret",
            Version = TwitterSettings.OAuthVersion,
            CallbackUrl = TwitterSettings.CallbackUri
        };

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

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

private void TwitterRequestTokenCompleted(RestRequest request, RestResponse response, object userstate)
    {
        _oAuthToken = GetQueryParameter(response.Content, "oauth_token");
        _oAuthTokenSecret = GetQueryParameter(response.Content, "oauth_token_secret");
        var authorizeUrl = TwitterSettings.AuthorizeUri + "?oauth_token=" + _oAuthToken;

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

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

并且您可以对访问令牌执行相同的操作。

于 2013-10-08T09:17:18.237 回答
0

您是否检查过 TweetSharp 库是否支持 Windows Phone 8?

于 2013-08-13T21:33:48.153 回答