Pull twitter profile image

2019-01-21 08:32发布

Is there a quick way to pull twitter profile image in PHP or Javascript? I need to get the url of the FULL image (not avatar size). Thanks. Any code sample is good.

8条回答
Root(大扎)
3楼-- · 2019-01-21 08:58
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

查看更多
登录 后发表回答