Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pull twitter profile image

Tags:

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.

like image 566
HP. Avatar asked Jan 22 '10 04:01

HP.


People also ask

Is there a reverse image search for Twitter?

The process is simple when using TweetDeck, first select a tweet containing an image, open the image and in the top left corner a small magnifying glass will appear (see below). Clicking the magnifying glass will open Google's Reverse Image Search in a new browser window.

What is profile banner in Twitter?

Profile banners allow users to further customize the expressiveness of their profiles. Use POST account/update_profile_banner to upload a profile banner on behalf of a user. Profile banners come in a variety of display-enhanced sizes.

How do I get a Twitter hexagon?

Having a hexagonal Twitter profile picture on your account signifies that you're an NFT investor. The only way to get these hexagonal avatars is by connecting your secure cryptocurrency wallet to your Twitter account. These days, more people understand the concepts behind cryptocurrency than ever before.


2 Answers

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.

like image 195
abraham Avatar answered Sep 30 '22 06:09

abraham


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

like image 37
Adam V. Avatar answered Sep 30 '22 06:09

Adam V.