我尝试构建一个 Windows 8 应用程序,我将在其中集成 Twitter。所以没有回调URL。经过长时间的搜索,我已经获得了用户令牌和秘密。现在我尝试获取用户时间线。但我总是得到 401 Unauthorized 或在响应“无法验证您”中出现错误 32。我使用 OAuth 工具生成授权标头和签名基本字符串,以将其与我发送的值进行比较。它们看起来和我很相似,除了随机数。
GET&https%3A%2F%2Fapi.twitter.com%2F1.1%2Fstatuses%2Fhome_timeline.json&oauth_consumer_key%3DGszx6r0cSieo3OwyH3SA%26oauth_nonce%3D4387f13969df533a0b0a294d9884506b%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1371117616%26oauth_token%3D1470508532-5JPWuH66asacc45qGkKKYuP50QEPOA55VrXfV9o%26oauth_version%3D1.0
GET&https%3A%2F%2Fapi.twitter.com%2F1.1%2Fstatuses%2Fhome_timeline.json&oauth_consumer_key%3DGszx6r0cSieo3OwyH3SA%26oauth_nonce%3D190930700%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1371117905%26oauth_token%3D1470508532-5JPWuH66asacc45qGkKKYuP50QEPOA55VrXfV9o%26oauth_version%3D1.0
Authorization: OAuth oauth_consumer_key="Gszx6r0cSieo3OwyH3SA", oauth_nonce="4387f13969df533a0b0a294d9884506b", oauth_signature="QQOO4aUJx9%2FNKYidvuPx%2Fv7YzNg%3D", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1371117616", oauth_token="1470508532-5JPWuH66asacc45qGkKKYuP50QEPOA55VrXfV9o", oauth_version="1.0"
Authorization: OAuth oauth_consumer_key="Gszx6r0cSieo3OwyH3SA", oauth_nonce="701369537", oauth_signature="VKjaVFHL%2FgtCRCASW5qdQtE%2BiJA%3D", oauth_signature_method="HMAC-SHA1",oauth_timestamp="1371118662", oauth_token="1470508532-5JPWuH66asacc45qGkKKYuP50QEPOA55VrXfV9o", oauth_version="1.0"
第一个代码来自 OAuth 工具,第二个是我的代码。
谢谢马洛