Broken urls for old profile images


#1

How does Twitter move around profile images between domains? For an old image like http://a0.twimg.com/profile_images/378800000080908923/1ebd28c409e1079c33476f5fbed03bf6_reasonably_small.jpeg I get the following error:

<?xml version="1.0" encoding="UTF-8"?>
<Error><Code>AccessDenied</Code><Message>Access Denied</Message><RequestId>CCBDE976C4818895</RequestId><HostId>CDPVVBeIdHe0D9qf4L647kOjgWry9ev5CCxq2MQTqZuMJ3ngnHwjs80NkJnrE6sZ</HostId></Error>

Somethimes when I refresh, I see the image. Whats wrong? Is it possible to redirect the wrong urls to the correct current location of the profile image?


#2

Unfortunately we’re seldom consistent in how these have been persisted over the years. Over the past few months we’ve gradually moved much of the underlying avatar infrastructure to new hosts and data services and you’ll likely be seeing profile image URLs pointing to these new hosts now when requesting user objects. I’m unsure of the length of time older URLs will continue functioning.


#3

Is it possible to find out what the length of time for older URLs is? Also for the different versions of the images (_normal, _bigger, _reasonably_small and the original size).

Do you move all old images to pbs.twimg.com instead of a*.twimg.com?


#4

Hello Jack,

Thank you for your question. You are correct, profile images are now exposed from pbs.twimg.com, which should be seamless by using the profile_image_url and profile_image_url_https from the REST API. We have updated the documentation to reflect the host change: [node:10796].

If you encountering any 403 or 404 errors while trying to access profile images, please make sure to have up-to-date user objects. Indeed, chances are the images moved hosts or the users have changed their profile images; I am not sure how long URLs continue working in that latter case. In any case, the recommendation is to call the [node:10320] endpoint to gather the most recent profile image URL.

Please let us know if you have any other questions or issues.


#5

Hi Romain,

I think part of the problem here is that images on the old hosts are available to some clients (users), and not to others.

This host change is troublesome when you have millions of cached images, as updating them is far from easy.

Can you clarify - if a user’s current profile url is now on pbs, and the user uploads a new avatar, will the old one be retained on pbs also?

Thanks,

Tim.


#6

Hi Romain,

Thanks for your reply. I got the latest version of the image working, but not older ones. It worked before, but now all the old images are broken. We really need to have the correct url for the old images because thats one of the main functions from our website. Check http://bioischanged.com/user/romainhuet for an example.

Jack


#7

The only way to get consistent results is to first fetch the profile_image_url from from users/show. We understand that this situation in not ideal but it will take a while for all the caches to expire for the old images (with legacy URLs).


#8

We have been talking to the engineers and the expected behavior is to have profile images cached for 7 days at the new location (pbs.twitter.com).

You should also make sure you use profile_image_url_https — The HTTP version should not work anymore so we will need to update the API.

Please let us know if this does not work as expected.


#9

Romain, thanks for the clear statement. That’s enough detail to create a plan for.

As an observation, 7 days is a pretty short time. If I’m wanting to reliably show avatars for the 1000 users who retweeted a tweet, I’m going to have to start making a lot more calls to the twitter API (for both favstar users and non-users) to keep avatars updated.


#10

Does this mean that you no longer save old profile images? (Also see my comment above https://dev.twitter.com/discussions/22410#comment-58060)


#11

That is correct, Jack. We understand your use case, but old profile images used to be available only as a side effect of the caching system, not from a documented API functionality.


#12

Yes, what is the recommended way for apps to keep the avatar URLs up to date now? It seems like a lot of GET users/show calls will have to be constantly made to poll for changes.