I'm creating a web application with php and JavaScript that will get a user's details from twitter. I have tried reading the documentation at https://dev.twitter.com/docs/api/1/get/users/show but could't understand anything. I found very little relevant documentation on the subject. I need to see a sample code for a tutorial. Anyone with Ideas?
Take my Twitter account, for example. My screen name is charliekilian
. So if you go to this URL:
https://api.twitter.com/1/users/show.json?screen_name=charliekilian&include_entities=true
you will get back a JSON entity about my account. In other words, you issue the request via HTTP GET, and it will respond with a document that is structured as a JSON object that you can parse to figure out the data.
If you want data on a different user, replace the portion of the URL that is my username with the username you are looking for.
The way i would handle this is by using:
$username = ''; // Twitter Username
$page_data = file_get_contents("https://api.twitter.com/1/users/show.json?include_entities=true&screen_name=$username");
Then search $page_data
for the specific details you want, using preg_match()
to match regex patterns for the data you're looking for.
I also found this, which is along the same lines, but without regex.
http://tareq.wedevs.com/2009/05/playing-with-twitter-json-using-php/
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.