The profile_image redirect does not work when requested from an IOS/Android device


#1

The profile_image redirect https://twitter.com/[screen_name]/profile_image?size=original does not work when requested from an IOS/Android/mobile device.

To test: (the user-agent is trimmed for brevity)

curl 'https://twitter.com/Twitter/profile_image?size=normal' -A 'Mozilla/5.0 (iPhone)'

redirects via javascript to https://mobile.twitter.com/Twitter/profile_image?size=normal instead.

On the desktop, the redirect works, with a HTTP 302 to https://pbs.twimg.com/profile_images/530553072594874368/7f9QErOD_normal.png.


How to get user image original size with API 1.1
#2

Thanks for the report. We’re tracking this internally as PREL-11155.


#3

@isaach any updates on that ?


#4

Has any progress been made here?


#5

Yes, this was resolved some time ago, but in the meantime Isaac moved on so was unable to report back. I’ve double-checked locally that this should now work as expected.


#6

Hey @andypiper, thanks for the quick reply. From the testing I’ve done, it looks like it often works, but still fails when both of the following are true:

  1. You are using a mobile device (such as “iPhone” or “iPad” in the user-agent string)
  2. You are signed in (such that a valid auth_token exists in the request cookies)

When testing against https://twitter.com/Twitter/profile_image all desktop clients received a 302 to the profile image on pbs.twimg.com, and all mobile clients received a 302 to the mobile version at https://mobile.twitter.com/Twitter/profile_image

When testing against https://mobile.twitter.com/Twitter/profile_image all desktop clients (again) received a 302 to the profile image on pbs.twimg.com. For mobile clients, the response was dependent on whether or not the auth_token cookie was present. Without the auth_token, mobile clients also got the 302 to the profile image on pbs.twimg.com. With the auth_token, mobile clients received a 200 status with HTML payload.

Let me know if you have any questions, and I’ll provide further details if possible.

Thanks!


#7

Still doesn’t work on iOS/Safari. Even though my HTML looks like this:

<img src="https://twitter.com/Falloutt/profile_image?size=bigger">

from the Safari debugger I see a network request to

https://mobile.twitter.com/Falloutt/profile_image?size=bigger

which returns a 200 html page saying

Sorry, that page doesn't exist!
Why not try a search to find something else?

Any update on this?


#8

I still see this issue. I can’t access user profile images from iOS because I’m redirected to a mobile.twitter.com site.


#9

I’m also seeing the same problem; with a user-agent applied the redirect to mobile.twitter.com results in a 404.

Can we have an update please?


#10

This changed last year when we rolled out our new mobile web UI. As that endpoint is not a part of the developer platform as such, it is difficult to know whether this is something that “should” work via a direct lookup from a mobile browser - the canonical profile image URLs are served up in the API from the JSON user object, rather than via a web redirect like this (which was a legacy feature).

I’ll certainly raise it with the mobile web folks, but I’m not able to commit that this is something that will be prioritised soon.


#11

The example API on the twitter developers page (GET https://api.twitter.com/1.1/users/show.json?screen_name=twitterdev) does not work, instead it just returns: {“errors”: [{" Bad Authentication data. "}]} How do I authenticate in this url? What is the authentication parameter?


#12

You need to use Oauth on the request. If you’d like to test this I advise using twurl. Alternatively choose a third party Twitter API library with Oauth built-in.


#13

Same error for me on iOS simulator and real device. Probably the “fix” for now it’s just to hide the images on iOS…


#14

Are you talking about getting a user profile image in general?

If you use Twitter Kit you can make authenticated requests to the API I listed above to get a profile image.


#15

@andypiper I’m talking about getting a profile image from a web browser, this is a webapp not a native app.

Also this is a list with a lot of tweets, I can’t make a request for each image that I want to get.


#16

Hello,

I’m bumping this thread.

Like others said it’s not convenient. Imagine storing hundred or thousand of tweet,
we can not do an API query for each one, just to be sure the avatar still works.

Facebook does actually provide the same feature
https://graph.facebook.com//picture
You just have to have the user_id

Even for twitter itself it’s not good, if we display broken avatar, your product feels broken too.

This 3years issue just tell developpers/salesman that twitter is a not a good things to use,
because we can not unsure a reliable way to display tweets (not counting the js sdk that works great)
Which is a shame, because twitter is a wonderfull plateform to discuss and exchange.

Best regards,


#17

With the recent full launch of Twitter Lite on mobile.twitter.com there are no plans to change the behaviour for accessing profile images. You will need to do so via the documented and supported API.