users/profile_image Documentation

eviljordan
@eviljordan Jordan Holberg

First, something changed in the Rest API for retrieving user images. This has happened in the past few days, without warning, unless I missed it.

The new format is:
http://api.twitter.com/1/users/profile_image?screen_name=USERNAME&size=bigger

It used to be:
http://api.twitter.com/1/users/profile_image/USERNAME.json?size=bigger

This bit of the docs located here: https://dev.twitter.com/docs/api/1/get/users/profile_image/%3Ascreen_name
says this:
This method must not be used as the image source URL presented to users of your application.

Why not? What is the proposed solution, then, for displaying a user's image in browser? pre-fetching all images then returning the actual URL by reading the headers? That's ridiculous.

2 years 39 weeks ago

Replies

KimMeerkat
@KimMeerkat SARA KIM HOLLY

still no follow button on profile where it should be says edit profile tryed everything
when i am in myspace i click on my profile which is http://twitter.com/kimmeerkat that takes me to
twitter profile know my myspace profile is urlmyspace.com/571018965 how do i join these to things
together so people click on it from twitter to go to myspace i am trying my best i am sorry for all this
please help sara kim

2 years 39 weeks ago
episod
@episod Taylor Singletary

Hi Sara Kim,

This is a developer support site, not meant for general user support which you can find at http://help.twitter.com

I looked at your profile and saw that the URL you've put on your profile is your own Twitter URL. You'll want to change that to http://myspace.com/571018965 by editing your profile on https://twitter.com/settings/profile .. Your Twitter profile will then have a link to your Myspace profile.

2 years 39 weeks ago
episod
@episod Taylor Singletary

Hi @eviljordan,

The preferred URL format has changed though your older URLs will continue working for the foreseeable future. The changed format is clearer and

You are correct that you can't use these URLs in IMG SRC tags -- the reason is because they are API URLs and they count against rate limiting and go through the stack to be served. That does not scale. If you're using this method to obtain avatar image URLs you should cache the result. The URLs also invoke a redirect which is not a smart behavior to use for IMG SRC tags.

If you're showing avatars in the context of tweets, the avatar image URL is included in the embedded user object of the tweet. You can also get the current avatar image URL for the user by executing users/show or bulk users/lookup. This API method is most often used for backfilling, updated cached user data, and other indirect uses.

2 years 39 weeks ago
eviljordan
@eviljordan Jordan Holberg

Thanks for the info, @episod.

Interesting about the not scaling part... this is exactly how facebook delivers all of their images, and that seems to work fine, with no warnings not to do it: https://graph.facebook.com/eviljordan/picture?type=large

If I'm caching the images, though, what happens when the user updates their image? If I'm calling an image directly, I'll never know if it's been updated by just referencing the actual img src instead of calling the API.

I am not showing images in the context of tweets, but as user avatars for single sign on.

2 years 39 weeks ago
eviljordan
@eviljordan Jordan Holberg

Now might be a good time to mention the undocumented size=original option, too.

1) Why is this undocumented?
2) When trying to access a size=original for a user that has protected their tweets, an api error is returned, instead of the link to the image, which differs from passing any other available size parameter. Example: http://api.twitter.com/1/users/profile_image?screen_name=DVDADO&size=original vs. http://api.twitter.com/1/users/profile_image?screen_name=DVDADO&size=normal

2 years 39 weeks ago
themattharris
@themattharris Matt Harris
  1. Thanks for highlighting that. We'll add that in.
  2. What is the error that is returned? When I make a request for a protected users avatar it is returned for me.

When caching images it is up to you how long you wish to cache avatars for. In some cases developers prefer to synchronise once a day, other times they wait until the user signs in again. In either case you can always obtain the most up to data avatar (and other information) using the methods @episod described.

Hope that helps.

2 years 39 weeks ago
eviljordan
@eviljordan Jordan Holberg

Man, you were on a posting reply binge!

This morning, I am getting an image rendered with text that says, 'The image "http://a3.twimg.com/sticky/default_profile_images/default_profile_4_original.png" cannot be displayed because it contains errors.' Seems like it should return a giant or normal size version of the Egg instead, no?

Last night, I was receiving an XML error response, which I stupidly didn't document.

2 years 39 weeks ago
eQRoeil
@eQRoeil Pascal C

Hello, I was doing some testing (i'm new with Twitter api)
I wanted to show all the profile images of a user.
Unfortunately I used this kind of URL https://dev.twitter.com/docs/api/1/get/users/profile_image/%3Ascreen_name ... rate limited.

I've read https://dev.twitter.com/docs/api/1/get/users/lookup and https://dev.twitter.com/docs/api/1/get/users/show but I'm not sure how to
- get all the followers of one user
- get the profile image of each follower
and be sure to not abuse the rate limit

How to be sure that I have not be blacklisted ?

2 years 32 weeks ago
MohdIntikhab
@MohdIntikhab mohd intikhab

hello

1 year 20 weeks ago