【问题标题】:Twitter API 1.1: Getting friends list from twitterTwitter API 1.1:从 twitter 获取好友列表
【发布时间】:2013-07-25 22:13:16
【问题描述】:

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

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

但结果是:

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

【问题讨论】:

    标签: twitter


    【解决方案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-06-22
      • 1970-01-01
      • 2012-12-05
      • 1970-01-01
      • 2011-12-12
      • 2013-06-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多