Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to fetch twitter user feeds using PHP

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 114
    Comment on it

    If you want to display twitter user feeds then use the below code of flow.

    First of all for user timeline json you have to visit below twitter link.

    http://dev.twitter.com/doc/get/statuses/user_timeline

    For detail parameter please visit.

    http://apiwiki.twitter.com/w/page/22554679/Twitter-API-Documentation

    function twi_fid(){
    
     ## NUMBER OF TWITTET 
     $size = 5;
    
     ## FETCH THE TWITTER TWITTET
     $twittet = file_get_contents("http://api.twitter.com/1/statuses/user_timeline.json?screen_name=bdsarwar&count=$size&include_rts=t&include_entities=t");
    
    
     $data = json_decode($twittet);
     $o_text = "";
     foreach($data as $t)
     {
         $o_text = $t->text;
    
         ## MAKING URLS ENABLE TO TEXT
         $entities = $t->entities;
    
         $i = 0;
         foreach($entities->urls as $url)
         {
             $indicate = $url->indices;
    
             $replace[$i] = $url->url;
             $string[$i] = "<a target='_blank' href='".$url->url."'>".$url->url."</a>";
    
    
             $i++;
         }
    
         ## MAKING MENTIONS 
         foreach($entities->user_mentions as $mention)
         {
             $indicate = $mention->indices;
    
             $string[$i] = "<a target='_blank' href='http://www.twitter.com/".$mention->screen_name."'>".$mention->screen_name."</a>";
             $replace[$i] = $mention->screen_name;
    
             $i++;
         }
    
         for($i = 0; $i < count($string); $i++)
         {
    
             $pattarn = $replace[$i];
             $o_text = str_replace($pattarn, $string[$i], $o_text);
    
         }
    
       echo $o_text;
       echo "<br />";
       echo date("d/m/Y, H:m a", strtotime($t->created_at));
       echo "<br/> ___ <br />";
    
    
     }
     }
     twi_fid();
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: