Saswat
Saswat

Reputation: 12836

Retrieving Twitter data based on Twitter ID in CodeIgniter using OAuth

I am using a script to fetch data of a particular Twitter user id. The twitter user id is 1897279429.

I want to show its name and image. I have the following script using the Twitter library.

        $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();

The issue is that I want the name and the URL of the profile picture to be displayed, but instead I get the following:

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

Now it may be because I don't have any follower, and the URL is wrong. But I want the appropriate way and URL.

Upvotes: 0

Views: 483

Answers (1)

Ben
Ben

Reputation: 4331

It's not just you. I just put that user ID into a Twython script I have to look them up and got this:

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$ 

So there you have it, whoever that was has been suspended.

Upvotes: 1

Related Questions