FREE LOOK
Wednesday, September 27, 2017
Twitter users data using php api version 1 0
Twitter users data using php api version 1 0
I think you want to display your twitter update into your web. I coded it using curl and it display the twitter data without authentication.
You can see the demo.
Code:
<?php /** * * Description: Twitter users feed without aouth (V1.0). * * Author: Md. Mahedi Azad * Email: mahediazad@gmail.com * Web: www.mahediazad.info * Date: 14 Mar 2013 * **/ /** * var $username the twitter username * var $feednumber the feed number in wall to display * **/ function get_data($username, $feednumber=3) { $url = "https://api.twitter.com/1/statuses/user_timeline.json?include_entities=true&include_rts=true&screen_name=$username&count=$feednumber"; $ch = curl_init(); $timeout = 5; curl_setopt($ch,CURLOPT_URL,$url); curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); $data = curl_exec($ch); curl_close($ch); return $data; } $json = get_data(mahediazad); //calling function if ($json != false) { $obj = json_decode($json); //decoding the data in json //Displaying the json datra foreach($obj as $var => $value) { echo "Message number: $var <br/>"; echo "Name: " . $obj[$var]->user->name. "<br/>"; echo "Handle: " . $obj[$var]->user->screen_name . "<br/>"; echo "Message: " . $obj[$var]->text. "<br/>"; echo "Created: " . $obj[$var]->created_at . "<br/>"; echo "URL: " . $obj[$var]->user->url . "<br/>"; echo "Location: " . $obj[$var]->user->location . "<br/>"; echo "<br/>"; } } else { echo "Could not fetch Twitter data"; } ?>
download
file
now
Newer Post
Older Post
Home