Cakephp twitter api 1.1错误HTTP / 1.1 400错误请求内容长度:0连接:关闭

时间:2013-09-28 02:52:14

标签: twitter cakephp-2.3

我在使用带有cakephp的twitter API 1.1时遇到问题。 当我调用https://api.twitter.com/1.1/search/tweets.json来搜索推文时,响应总是返回HTTP / 1.1 400 Bad Request Content-Length:0 Connection:close。

我检查此请求的原始请求:

GET /1.1/search/tweets.json HTTP/1.1
Host: api.twitter.com
Connection: close
User-Agent: CakePHP
Authorization: 
OAuth oauth_version="1.0",
oauth_signature_method="HMAC-SHA1",
oauth_token="822896990-Eazz9XQVzZ2I9l53pRhbGKxsxxxxxxxxxxx",
oauth_consumer_key="T1rqat2i3nV30xxxxxxxx",
oauth_nonce="652bbdc4c9e2f91a16c7f166xxxxxxxx",
oauth_timestamp="1380334675",
oauth_signature="4HYs4uPTxOOGtA%2F6uHxxxxxxxxxxx"
Content-Type: application/x-www-form-urlencoded
Content-Length: 9

q=datnoid

但是当我打电话给api:https://api.twitter.com/1.1/statuses/show/ $ id。'。json' 它返回结果OK。

请求raw:

GET /1.1/statuses/show/382331096781692928.json HTTP/1.1
Host: api.twitter.com
Connection: close
User-Agent: CakePHP
Authorization: OAuth oauth_version="1.0",
oauth_signature_method="HMAC-SHA1",
oauth_token="822896990-Eazz9XQVzZ2I9l53pRhbGKxsHi2Yxxxxxxxxxxxxxx",
oauth_consumer_key="T1rqat2i3nV30xxxxxxxxxx",
oauth_nonce="78a8b446ea3c9cba1ff0exxxxxxxxxx",
oauth_timestamp="1380334472",
oauth_signature="hTKPIvUh6F9XxCxhgClQjxxxxxxxxxxxx"

两个请求之间唯一不同的是第一个请求参数搜索[q = datnoid],第二个请求根本没有参数!

我做错了什么?

1 个答案:

答案 0 :(得分:0)

我找到了解决方案,我使用的推特组件有错误的代码。 它为所有get / post方法传递请求[body]的参数。