0

我正在使用脚本来获取特定 Twitter 用户 ID 的数据。推特用户 ID 是1897279429.

我想显示它的名称和图像。我有以下使用 Twitter 库的脚本。

        $this->load->config('twitter');
        require_once APPPATH.'libraries/TwitterAPIExchange.php';
        $settings = array(
            'oauth_access_token' => $this->config->item('access_token'),
            'oauth_access_token_secret' => $this->config->item('access_token_secret'),
            'consumer_key' => $this->config->item('consumer_key'),
            'consumer_secret' => $this->config->item('consumer_secret')
        );


        /** Perform a GET request and echo the response **/
        /** Note: Set the GET field BEFORE calling buildOauth(); **/
        $url = 'https://api.twitter.com/1.1/followers/ids.json';
        $getfield = '?username=SaswatRoutroy';
        $requestMethod = 'GET';
        $twitter = new TwitterAPIExchange($settings);
        echo $twitter->setGetfield($getfield)
                    ->buildOauth($url, $requestMethod)
                    ->performRequest();

问题是我希望显示个人资料图片的名称和 URL,但我得到以下信息:

{"ids":[],"next_cursor":0,"next_cursor_str":"0","previous_cursor":0,"previous_cursor_str":"0"}

现在可能是因为我没有粉丝,而且网址错误。但我想要适当的方式和网址。

4

1 回答 1

1

不只是你。我只是将该用户 ID 放入 Twython 脚本中,我必须查找它们并得到以下信息:

bash-3.2$ ./id-show.py 
User to show: 1897279429
Traceback (most recent call last):
  File "./id-show.py", line 14, in <module>
    data = twitter.show_user(user_id=target)
  File "build/bdist.macosx-10.3-fat/egg/twython/endpoints.py", line 426, in show_user
  File "build/bdist.macosx-10.3-fat/egg/twython/api.py", line 230, in get
  File "build/bdist.macosx-10.3-fat/egg/twython/api.py", line 224, in request
  File "build/bdist.macosx-10.3-fat/egg/twython/api.py", line 194, in _request
twython.exceptions.TwythonError: Twitter API returned a 403 (Forbidden), User has been suspended.
bash-3.2$ 

所以你有它,无论是谁已经被停职。

于 2013-09-29T19:27:47.823 回答