我们需要传递哪些参数和标头才能使用 REST API 连接到 Twitter



我正在尝试使用Java通过REST API连接到Twitter。我正在使用 POST 将以下查询参数传递给

https://api.twitter.com/1/statuses/update.json.
include_entities=true
oauth_consumer_key=**********
oauth_consumer_secret=************
oauth_nonce=***********
oauth_signature_method=HMAC-SHA1
oauth_timestamp=1340329822
oauth_token=***************
oauth_version=1.0
status=test msg

连接到Twitter的实际过程是什么?首先我需要使用授权请求获取auth_token,然后发出 update.json 请求?

无论我有什么

要求,我都会收到任何问题

{"error":"Could not authenticate you.","request":"/1/statuses/update.json"}

但是我检查了我所有的配置参数(密钥/机密),它们是正确的。我尝试使用 Twitter4J 连接相同的参数并且工作正常。

当我尝试使用相同的参数从 REST 客户端工具 (http://code.google.com/a/eclipselabs.org/p/restclient-tool/) 调用时,它失败了。

有什么帮助吗?

您必须在名为"授权"的标头中传递oauth_*参数,而不是使用其他POST参数。在推特API文档中有解释 https://dev.twitter.com/docs/auth/authorizing-request:

最新更新