2

如何获取通过我的 twitter 应用程序认证的用户的所有关注者(朋友)。根据 twitter docs,我尝试过以下一种

https://api.twitter.com/1.1/friends/ids.json?cursor=-1&screen_name=<user_screen_name>

但结果是:

{"errors":[{"message":"Bad Authentication data","code":215}]}
4

1 回答 1

1

您的调用需要使用 oAuth,即使屏幕名称已授权您的 Twitter 应用程序,纯 URL 调用也不起作用。

您需要为已显示的 URL 构造一个 HTTP GET,但要使用格式正确的授权标头 (oAuth)。

它实际上是一个带有“授权”键和生成值的 Web 请求标头,如下所示:

OAuth realm="<name of realm, e.g. Twitter API>",
oauth_consumer_key="<your app key, you'll know this already from your twitter app>",
oauth_nonce="<this is basically a random alphanumeric string which your app should generate>",
oauth_timestamp="<number of seconds since 1/1/1970 00:00:00",
oauth_signature_method="HMAC-SHA1",
oauth_version="1.0",
oauth_signature="<this is the trickiest part, you basically have to hash the request + two secret params through a signing algorithm using the signature method above>"

有关更多信息,请参见此处: https ://dev.twitter.com/docs/auth/authorizing-request

于 2013-07-25T14:13:16.297 回答