Pull twitter profile image

后端 未结 8 2009
有刺的猬
有刺的猬 2020-12-12 23:28

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条回答
  • 2020-12-13 00:25

    When you get original image link, you can modify it to get bigger. http://pbs.twimg.com/profile_images/34543543/image_name_normal.jpg

    becomes

    http://pbs.twimg.com/profile_images/34543543/image_name.jpg or image_name_bigger, ...

    Source: https://dev.twitter.com/docs/user-profile-images-and-banners

    0 讨论(0)
  • 2020-12-13 00:27
    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

    0 讨论(0)
提交回复
热议问题