1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

twitter api and curl help

Discussion in 'PHP & Perl' started by ebraheeemz, Jan 2, 2014.

  1. ebraheeemz

    ebraheeemz Registered Member

    Joined:
    Oct 13, 2013
    Messages:
    58
    Likes Received:
    2
    Location:
    Jordan
    Hello
    can i get a list of all followers for specific person using php curl??
    thanks
     
  2. webwhizz

    webwhizz Power Member

    Joined:
    Apr 3, 2011
    Messages:
    692
    Likes Received:
    656
    Occupation:
    P-R-0
    Location:
    scotland
    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]

     
    • Thanks Thanks x 1
  3. barigain

    barigain Junior Member

    Joined:
    Aug 23, 2012
    Messages:
    100
    Likes Received:
    12
    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);
    
     
  4. ebraheeemz

    ebraheeemz Registered Member

    Joined:
    Oct 13, 2013
    Messages:
    58
    Likes Received:
    2
    Location:
    Jordan
    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: Jan 3, 2014