0

我正在使用吊床推特库发布并从推特获取朋友列表。以前它工作正常。但现在只有 request_token 部分在工作。在尝试获取访问令牌和用户 ID 时,屏幕名称得到“OK”服务器响应。但结果看起来像这样:

���Dͻ�0@�as�"Ё��&b�������������8���h9�v�r<{g�/�XR>�e��.>~�rH�5�Z� �_�~�+Kn9��)��£��sU��)��������|�TV6!�B��2(����֚V`�!��@4�� � ���?d�</p>

我不知道为什么我会得到这个.. :(

下面是我的代码

Public Sub GetRequestToken(Consumer_KEY As String, Consumer_Secret_Key As String)
    Dim credentials = New OAuthCredentials
    credentials.Type = OAuthType.RequestToken
    credentials.SignatureMethod = OAuthSignatureMethod.HmacSha1
    credentials.ParameterHandling = OAuthParameterHandling.HttpAuthorizationHeader
    credentials.ConsumerKey = TwitterSettings.ConsumerKey
    credentials.ConsumerSecret = TwitterSettings.ConsumerKeySecret
    credentials.Version = TwitterSettings.OAuthVersion
    credentials.CallbackUrl = "oob"

    Dim client = New RestClient
    client.Authority = "https://api.twitter.com/oauth"
    client.Credentials = credentials
    client.HasElevatedPermissions = True

    Dim request = New RestRequest
    request.Path = "/request_token"

    client.BeginRequest(request, New RestCallback(AddressOf TwitterRequestTokenCompleted))
End Sub

Public Sub TwitterRequestTokenCompleted(request As RestRequest, response As RestResponse, userstate As Object)
    result = Regex.Split(response.Content, "&")
    oauth_token = Regex.Split(result(0), "=")(1)
    oauth_secret_token = Regex.Split(result(1), "=")(1)
    request_url = TwitterSettings.AuthorizeUri + "?oauth_token=" + oauth_token
    case_url = "request"
    Deployment.Current.Dispatcher.BeginInvoke(getresult)
End Sub

解析oobpin 后,我请求访问令牌:

Public Sub GetAccessToken(Verifier As String)
    Dim credentials = New OAuthCredentials
    credentials.Type = OAuthType.AccessToken
    credentials.SignatureMethod = OAuthSignatureMethod.HmacSha1
    credentials.ParameterHandling = OAuthParameterHandling.HttpAuthorizationHeader
    credentials.ConsumerKey = TwitterSettings.ConsumerKey
    credentials.ConsumerSecret = TwitterSettings.ConsumerKeySecret
    credentials.Token = oauth_token
    credentials.TokenSecret = oauth_secret_token
    credentials.Verifier = Verifier

    Dim client = New RestClient
    client.Authority = "https://api.twitter.com/oauth"
    client.Credentials = credentials
    client.HasElevatedPermissions = True

    Dim request = New RestRequest
    request.Path = "/access_token"

    client.BeginRequest(request, New RestCallback(AddressOf RequestAccessTokenCompleted))

以前有人遇到过吗?我需要这个尽快..只是困惑这是怎么突然发生的。在此先感谢极客;)

4

0 回答 0