在user_timeline上获得403 Forbidden,但在任何其他API上都没有

Getting 403 Forbidden on user_timeline but not on any other API

本文关键字:任何 其他 API Forbidden user timeline      更新时间:2023-09-26

使用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禁止,但在其他api上使用相同的代码,例如搜索/推文它工作得很好。我遗漏了什么?不,用户不是私有的

所调用的URL出现错误。应该是:

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