Skip to content

Instantly share code, notes, and snippets.

@jptksc
Created June 13, 2013 23:49
Show Gist options
  • Save jptksc/5778403 to your computer and use it in GitHub Desktop.
Save jptksc/5778403 to your computer and use it in GitHub Desktop.
Get a large Twitter profile image without having to deal with v1.1 API authentication.
function get_twitter_profile_img($username) {
$xml = simplexml_load_file('http://twitter.com/users/'.$username.'.xml');
return str_replace('_normal', '', $xml->profile_image_url);
}
@devinhalladay
Copy link

This should work as well:

function get_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);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment