首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Twitter停止工作(未经授权)

Twitter停止工作(未经授权)
EN

Stack Overflow用户
提问于 2014-03-20 08:40:32
回答 2查看 667关注 0票数 0

我使用自己的代码为twitter生成oauth请求,但它几天前就停止工作了(我刚才才注意到)。我现在切换到了特发性,但问题仍然是一样的(用一些XXXX替换了部分密钥):

代码语言:javascript
复制
* About to connect() to stream.twitter.com port 443 (#0)
*   Trying 199.16.156.110...
* connected
* Connected to stream.twitter.com (199.16.156.110) port 443 (#0)
* successfully set certificate verify locations:
*   CAfile: none
  CApath: /etc/ssl/certs
* SSLv3, TLS handshake, Client hello (1):
* SSLv3, TLS handshake, Server hello (2):
* SSLv3, TLS handshake, CERT (11):
* SSLv3, TLS handshake, Server finished (14):
* SSLv3, TLS handshake, Client key exchange (16):
* SSLv3, TLS change cipher, Client hello (1):
* SSLv3, TLS handshake, Finished (20):
* SSLv3, TLS change cipher, Client hello (1):
* SSLv3, TLS handshake, Finished (20):
* SSL connection using RC4-SHA
* Server certificate:
*        subject: C=US; ST=California; L=San Francisco; O=Twitter, Inc.; OU=Twitter Security; CN=stream.twitter.com
*        start date: 2013-10-09 00:00:00 GMT
*        expire date: 2016-12-30 23:59:59 GMT
*        subjectAltName: stream.twitter.com matched
*        issuer: C=US; O=VeriSign, Inc.; OU=VeriSign Trust Network; OU=Terms of use at https://www.verisign.com/rpa (c)10; CN=VeriSign Class 3 Secure Server CA - G3
*        SSL certificate verify ok.
> GET /1.1/statuses/sample.json HTTP/1.1
> User-Agent: curl/7.26.0
> Host: stream.twitter.com
> Accept: */*
> Authorization: OAuth oauth_consumer_key="XXXXXT0ayBaTgZ2w", oauth_nonce="XXXXXaa67fb89550XXXXXX", oauth_signature="XXXXXXWq2JQWiykA%3D", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1395304184", oauth_token="461014117-xXXXXXXXXXbgolyzewmAido0104sjmIV053U3e", oauth_version="1.0"
>
* additional stuff not fine transfer.c:1037: 0 0
* HTTP 1.1 or later with persistent connection, pipelining supported
< HTTP/1.1 401 Unauthorized
< WWW-Authenticate: OAuth realm="Firehose"
< Content-Type: text/html
< Cache-Control: must-revalidate,no-cache,no-store
< Transfer-Encoding: chunked
<
<html>\n<head>\n<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>\n<title>Error 401 Unauthorized</title>
</head>
<body>
<h2>HTTP ERROR: 401</h2>
<p>Problem accessing '/1.1/statuses/sample.json'. Reason:
<pre>    Unauthorized</pre>
</body>
</html>
* Connection #0 to host stream.twitter.com left intact
* Closing connection #0
* SSLv3, TLS alert, Client hello (1):

dev.twitter.com上的"Test dev.twitter.com“功能为我提供了一个执行工作的curl命令,因此我修改了PHP代码以输出这样的命令。然而,这是行不通的。同样的“未经授权”的错误;

Dev.twitter.com给我的Curl命令:

代码语言:javascript
复制
curl --get 'https://stream.twitter.com/1.1/statuses/sample.json' --header 'Authorization: 
OAuth oauth_consumer_key="XXXXX5BEGODmxg", 
oauth_nonce="XXXXX2c525ea3d3f86edfb", 
oauth_signature="b%2BpXXXXXXeC64%3D", 
oauth_signature_method="HMAC-SHA1", 
oauth_timestamp="1395304198", 
oauth_token="2280434016-BXXXXXXXXXXXXKgFautX3LVG", 
oauth_version="1.0"' --verbose

php代码中的Curl命令(不同的键,但当我使用与我的dev.twitter.com应用程序相同的键时,问题不会改变:)

代码语言:javascript
复制
curl --get 'https://stream.twitter.com/1.1/statuses/sample.json' --header 'Authorization: OAuth 
oauth_consumer_key="XXXXXT0ayBaTgZ2w", 
oauth_nonce="XXXXXXe8558d961bd398f1", 
oauth_signature="%2FXXXXXXeMUBj%2B2%2Bo%3D", 
oauth_signature_method="HMAC-SHA1", 
oauth_timestamp="1395304620", 
oauth_token="461014117-xXXXXXXXo0104sjmIV053U3e", 
oauth_version="1.0" ' --verbose

有人能说出为什么PHP代码中的那个不能工作吗?

更新:忘记提到我的TwitterOAuth设置:

代码语言:javascript
复制
$connection = new TwitterOAuth($consumer_key, $consumer_secret, $oauth_access_token, $oauth_access_token_secret);
$connection->timeout = $timeout;
$connection->ssl_verifypeer = false;
$connection->decode_json = false;

if($postfields !== false)
    return $connection->post($url, $postfields, $file);
else
    return $connection->get($url, $getfield, $file);
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2014-03-25 16:47:17

德普..。服务器的系统时钟是不同步的(如果在ze未来的几分钟内耦合的话),所以在将它设置回现在和现在之后,请求再次工作。

票数 0
EN

Stack Overflow用户

发布于 2014-03-20 08:57:30

您在--header-H参数下推送所有内容。一个接一个地使用。就像这个:

代码语言:javascript
复制
-H "Authorization: OAuth"
-H "oauth_nonce: XXXXXXe8558d961bd398f1"
-H "oauth_timestamp: 1395304620"
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/22527529

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档