使用fsock和oauth更新Twitter状态时出错500

时间:2010-09-06 11:29:18

标签: php twitter oauth fsockopen

我在Twitter Oauth和fsock上遇到了一些小问题。 我使用fsock的原因是为那些没有安装curl的人提供服务。

所以这就是我的问题。当我使用fsock更新twitter状态时,我能够使用fsock来获取访问令牌。它返回一个内部错误500。

以下是我发布的内容:

POST https://api.twitter.com/1/statuses/update.json HTTP/1.1
Host: api.twitter.com
Authorization: OAuth oauth_consumer_key=qArHWfcnikadIzP2k6EVg&oauth_nonce=bf07179df00bee93a9537ec12a1d7be6&oauth_signature=Ugs%2FGAPrtFIrRqhGQ9KrkrEYPVI%3D&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1283772251&oauth_token=177905108-JwUzEOE1ekGUbQieMBtB4P4L11WrEej6izvHQbJA&oauth_version=1.0&status=Published%20a%20new%20blog%20entry%20title%3AA%20Look%20Back%20%28and%20Forward%29%20at%20the%20Latest%20Tech%20Gadgets%20under%20category%3ATechnology
User-Agent: TwitterOAuth v0.2.0-beta2
Content-type: application/x-www-form-urlencoded
Connection: Close

这就是twitter回复我的原因:

HTTP/1.1 500 Internal Server Error
Date: Mon, 06 Sep 2010 11:24:06 GMT
Server: hi
Status: 500 Internal Server Error
Content-Type: text/html; charset=utf-8
Content-Length: 4659
Cache-Control: no-cache, max-age=300
Set-Cookie: k=110.159.136.116.1283772246202732; path=/; expires=Mon, 13-Sep-10 11:24:06 GMT; domain=.twitter.com
Set-Cookie: guest_id=128377224620512308; path=/; expires=Wed, 06 Oct 2010 11:24:06 GMT
Set-Cookie: _twitter_sess=BAh7BiIKZmxhc2hJQzonQWN0aW9uQ29udHJvbGxlcjo6Rmxhc2g6OkZsYXNo%250ASGFzaHsABjoKQHVzZWR7AA%253D%253D--1164b91ac812d853b877e93ddb612b7471bebc74; domain=.twitter.com; path=/
Expires: Mon, 06 Sep 2010 11:29:06 GMT
Vary: Accept-Encoding
Connection: close

非常感谢您的帮助。

1 个答案:

答案 0 :(得分:0)

POST https://api.twitter.com/1/statuses/update.json HTTP/1.1

你可能意味着:

POST /1/statuses/update.json HTTP/1.1

用以下方法打开套接字:

fsockopen("ssl://api.twitter.com", 443, $errno, $errstr, $timeout);