【问题标题】:Getting 403 Forbidden on user_timeline but not on any other API在 user_timeline 上获得 403 Forbidden 但在任何其他 API 上都没有
【发布时间】:2015-11-01 12:29:29
【问题描述】:

使用 API 验证

  var oauth2 = new OAuth2('Consumer Key', 'Consumer Secret', 'https://api.twitter.com/', null, 'oauth2/token', null);
  oauth2.getOAuthAccessToken('', 'grant_type': 'client_credentials' }, function (e, access_token) {

      console.log(access_token); //string that we can use to authenticate request

      requestURL = {
          url: 'https://api.twitter.com/1.1/statuses/user_timeline?user_id=' + userid,
          headers: {
              Authorization: 'Bearer ' + access_token
          }
      };




request(URL, function(error, response, body){ 
    console.log(request); 
    console.log(body); }

使用此代码,我得到 403 Forbidden,但在其他 API 上使用相同的代码,例如搜索/推文,它工作正常。 我在这里想念什么? 不,用户不是私人用户。

【问题讨论】:

    标签: javascript node.js twitter twitter-oauth


    【解决方案1】:

    您在调用的 URL 上遇到错误。应该是:

    ...
    url: 'https://api.twitter.com/1.1/statuses/user_timeline.json?user_id=' + userid,
    ...
    

    【讨论】:

    • 只需添加一个.json?
    • 没错,它会调用一个JSON服务。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-01-11
    • 1970-01-01
    • 2013-07-05
    • 2018-07-18
    • 2013-06-11
    • 2012-06-11
    相关资源
    最近更新 更多