加入收藏 | 设为首页 | 会员中心 | 我要投稿 东莞站长网 (https://www.0769zz.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 服务器 > 搭建环境 > Linux > 正文

卷曲,推特oauth问题

发布时间:2020-12-30 18:48:09 所属栏目:Linux 来源:网络整理
导读:有没有人看到下面的Curl调用/如何构建Oauth请求有问题? (我正在尝试获得正确的设置请求,以便我可以完成我的应用) 所以我打电话给以下CURL电话: C:curl -v -k --data-urlencode "status=Testing2" -H "Authorization: OAuth realm='',oauth_nonce=12761078

有没有人看到下面的Curl调用/如何构建Oauth请求有问题?
(我正在尝试获得正确的设置请求,以便我可以完成我的应用)
所以我打电话给以下CURL电话:

C:&;curl -v -k --data-urlencode "status=Testing2" -H "Authorization: OAuth realm='',oauth_nonce=1276107867blah,oauth_timestamp=1276107867,oauth_consumer_key=yJDLH7BDdVi1OKIINSV7Q,oauth_signature_method=HMAC-SHA1,oauth_version=1.0,oauth_signature=NWU4MDdlNjk0OGIxYWQ1YTkyNmU5YjU1NGYyOTczMmU5ZDg5

YWNkNA ==,staus = Testing2“http://twitter.com/statuses/update.xml?status=Testing2

我接受了这个:

* About to connect() to twitter.com port 80 (#0)
*   Trying 168.143.162.68... connected
* Connected to twitter.com (168.143.162.68) port 80 (#0)
> POST /statuses/update.xml?status=Testing2 HTTP/1.1
> User-Agent: curl/7.20.1 (i386-pc-win32) libcurl/7.20.1 OpenSSL/0.9.8n zlib/1.2.5 libidn/1.18 libssh2/1.2.5
> Host: twitter.com
> Accept: */*
> Authorization: OAuth realm='',oauth_nonce=1276106370blah,oauth_timestamp=1276106370,oauth_signature=MjQzNDA1MGU4NGRmMWVjMzUwZmQ4YzE5NzMzY2I1ZDJlOTRkNmQ2Zg==,staus=Testing2
> Content-Length: 15
> Content-Type: application/x-www-form-urlencoded
>
< HTTP/1.1 401 Unauthorized
< Date: Wed,09 Jun 2010 18:00:22 GMT
< Server: hi
< Status: 401 Unauthorized
< WWW-Authenticate: Basic realm="Twitter API"
< X-Runtime: 0.00548
< Content-Type: application/xml; charset=utf-8
< Content-Length: 164
< Cache-Control: no-cache,max-age=1800
< Set-Cookie: k=209.234.229.21.1276106420885412; path=/; expires=Wed,16-Jun-10 18:00:20 GMT; domain=.twitter.com
< Set-Cookie: guest_id=127610642214871948; path=/; expires=Fri,09 Jul 2010 18:00:22 GMT
< Set-Cookie: _twitter_sess=BAh7CDoPY3JlYXRlZF9hdGwrCIm33h0pAToHaWQiJTkyMjllODE0NTdiYWE1%250AMWU1MzBmNjgwMTFiMDhkYjdlIgpmbGFzaElDOidBY3Rpb25Db250cm9sbGVy%250AOjpGbGFzaDo6Rmxhc2hIYXNoewAGOgpAdXNlZHsA--8ebb3c62d461d28f8fda7b8adab642af66969f7e; domain=.twitter.com; path=/
< Expires: Wed,09 Jun 2010 18:30:20 GMT
< Vary: Accept-Encoding
< Connection: close
<
<?xml version="1.0" encoding="UTF-8"?>
<hash>
  <request>/statuses/update.xml?status=Testing2</request>
  <error>Could not authenticate with OAuth.</error>
</hash>
* Closing connection #0

我的参数设置如下:

var parameters = [encodeURIComponent("status="+status),encodeURIComponent("oauth_token="+ac_token),encodeURIComponent("oauth_consumer_key="+"yJDLH7BDdVi1OKIINSV7Q"),encodeURIComponent("oauth_nonce="+nonce,"oauth_signature_method=HMAC-SHA1"),encodeURIComponent("oauth_timestamp="+timestamp),encodeURIComponent("oauth_version=1.0")]

var join = parameters.join("&");
var eparamjoin =encodeURIComponent(join);

关键是这样的:

var key=con_secret+"&"+ac_secret;

签名基本字符串是:

var signaturebs = "POST&"+encodeURIComponent(url)+"&"+eparamjoin;

给这个:

POST&http%3A%2F%2Ftwitter.com%2Fstatuses%2Fupdate.xml&status%253DTesting2%26oauth_token%253D142715285-yi2ch324S3zfyKyJby6WDUZOhCsiQuKNUtc3nAGe%26oauth_consumer_key%253DyJDLH7BDdVi1OKIINSV7Q%26oauth_nonce%253D1276107867blah%26oauth_timestamp%253D1276107867%26oauth_version%253D1.0

和签名这样建立:

var hmac = Crypto.HMAC(Crypto.SHA1,signaturebs,key );

var signature=Base64.encode(hmac);

签名:

NWU4MDdlNjk0OGIxYWQ1YTkyNmU5YjU1NGYyOTczMmU5ZDg5YWNkNA==

任何帮助将不胜感激,谢谢!

解决方法

它可能像URL问题一样简单.

你在说:http://twitter.com/statuses/update.xml?status=Testing2

API文档建议:http://api.twitter.com/1/statuses/update.xml?status=Testing2

他们不久前实现了新的URL路径,但我不知道他们何时或是否关闭旧路径.

(编辑:东莞站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    热点阅读