Calling following_count

php

#1

So currently im trying to use the TwitterAPIExchange.php to grab the Twitter follower count of a specific user.

<?php

require_once('includes/config.php'); require_once('includes/TwitterAPIExchange.php'); 

$setting = array(
    'oauth_access_token' => "",
    'oauth_access_token_secret' => "", 
    'consumer_key' => "",
    'consumer_key_key' => ""
);
$url = "https://api.twitter.com/1.1/statuses/user_timeline.json";
$requestMethod = "GET";
if (isset($_GET['user']))  {$user = $_GET['user'];}
if (isset($_GET['count'])) {$count = $_GET['count'];} else {$count = 20;}
$getfield = "?screen_name=$twitter_username&count=$count";
$twitter = new TwitterAPIExchange($settings);
$string = json_decode($twitter->setGetfield($getfield)
->buildOauth($url, $requestMethod)
->performRequest(),$assoc = TRUE);
foreach($string as $items)
$twitterFollowers = $items['user']['followers_count'];

    
?>

$twitter_username is already defined in config.php

This isn’t coming back with any errors.


#2

It looks like you’re setting $user, but trying to use $twitter_username

Are you sure your $getfield is set properly?