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.