twitter api and curl help

ebraheeemz

Registered Member
Joined
Oct 13, 2013
Messages
59
Reaction score
2
Hello
can i get a list of all followers for specific person using php curl??
thanks
 
something like this should work using Abraham's twitter oauth api1.1


Code:
<?php$consumerKey = 'Consumer-Key';
$consumerSecret = 'Consumer-Secret';
$oAuthToken = 'OAuthToken';
$oAuthSecret = 'OAuth Secret';


# API OAuth
require_once('twitteroauth.php');


$tweet = new TwitterOAuth($consumerKey, $consumerSecret, $oAuthToken, $oAuthSecret);

lookup.php
Code:
[COLOR=#000000][FONT=Consolas]$tweet[/FONT][/COLOR][COLOR=#000000][FONT=Consolas]->[/FONT][/COLOR][COLOR=#00008B][FONT=Consolas]get[/FONT][/COLOR][COLOR=#000000][FONT=Consolas]([/FONT][/COLOR][COLOR=#800000][FONT=Consolas]'followers/ids'[/FONT][/COLOR][COLOR=#000000][FONT=Consolas],[/FONT][/COLOR][COLOR=#000000][FONT=Consolas] array[/FONT][/COLOR][COLOR=#000000][FONT=Consolas]([/FONT][/COLOR][COLOR=#800000][FONT=Consolas]'screen_name'[/FONT][/COLOR][COLOR=#000000][FONT=Consolas]=>[/FONT][/COLOR][COLOR=#800000][FONT=Consolas]'YOUR-SCREEN-USER'[/FONT][/COLOR][COLOR=#000000][FONT=Consolas]));[/FONT][/COLOR]


Hello
can i get a list of all followers for specific person using php curl??
thanks
 
Try the following code, but with specified API method instead of timeline:

Code:
$options = array(
    URLOPT_HTTPHEADER      => array('Authorization: OAuth oauth_consumer_key="YOUR_KEY", oauth_nonce="YOUR_NONCE", oauth_signature="YOUR_SIG", oauth_signature_method="HMAC-SHA1", oauth_timestamp="' . time() . '", oauth_token="YOUR_TOKEN", oauth_version="1.0"'),
    CURLOPT_HEADER         => false,
    CURLOPT_URL            => 'https://api.twitter.com/1.1/statuses/user_timeline.json?count=2&screen_name=twitter',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_SSL_VERIFYPEER => false
);


$feed = curl_init();
curl_setopt_array($feed, $options);
$json = curl_exec($feed);
curl_close($feed);


$twitter_data = json_decode($json);


var_dump($twitter_data);
 
Try the following code, but with specified API method instead of timeline:

Code:
$options = array(
    URLOPT_HTTPHEADER      => array('Authorization: OAuth oauth_consumer_key="YOUR_KEY", oauth_nonce="YOUR_NONCE", oauth_signature="YOUR_SIG", oauth_signature_method="HMAC-SHA1", oauth_timestamp="' . time() . '", oauth_token="YOUR_TOKEN", oauth_version="1.0"'),
    CURLOPT_HEADER         => false,
    CURLOPT_URL            => 'https://api.twitter.com/1.1/statuses/user_timeline.json?count=2&screen_name=twitter',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_SSL_VERIFYPEER => false
);


$feed = curl_init();
curl_setopt_array($feed, $options);
$json = curl_exec($feed);
curl_close($feed);


$twitter_data = json_decode($json);


var_dump($twitter_data);
thank you, your code work very good, but it give me just 200 followers, how can i get more than 20,000?
thanks
 
Last edited:
Back
Top