Pull twitter profile image Pull twitter profile image php php

Pull twitter profile image


Twitter has had a nice simple URL.

https://api.twitter.com/1/users/profile_image/abraham

It has size options like "?size=bigger"

You can read more about it on Little known Twitter and TwitterAPI tips and tricks.

Twitter now has documentation up as GET users/profile_image/:screen_name.

Update: Support for this method has been removed from v1.1 of the API. Recommended practice going forward is GET /users/show and cache profile_image_url locally in your service/app.


function get_big_profile_image($username, $size = '') {  $api_call = 'http://twitter.com/users/show/'.$username.'.json';  $results = json_decode(file_get_contents($api_call));  return str_replace('_normal', $size, $results->profile_image_url);}

get_big_profile_image('bobsaget', '_bigger') should return a large avatar:http://a1.twimg.com/profile_images/330305510/n229938150541_9850_bigger.jpg

get_big_profile_image('bobsaget') should return an even larger image: http://a1.twimg.com/profile_images/330305510/n229938150541_9850.jpg


Apologies if this is something that's now known, but I didn't see it documented anywhere during my searches, including the official Twitter docs.

You can add the ?size=original as a parameter, which will return the original uploaded image for the user.

So:http://api.twitter.com/1/users/profile_image/twitter.json?size=original