Twitter's reprehensible lack of an image API

Twitter's new image-hosting service contains no META or LINK tags to identify the encapsulated images; as is their way, everything is buried under 30 levels of intentionally-obfuscated iframe and Javascript nonsense.

Can anyone tell me how to get the URL of an image that I just posted?

For example, redirects to!/dnapizza/status/125447813940260864/photo/1 whose image is but I can't find any way to transform "125447813940260864" -- or any of the content actually present in the HTML source -- into "Ab2uH0QCMAA0dCh".

Since the Twitter iPhone app no longer allows you to specify a different image-hosting service, even that isn't an option here.

This is some serious bullshit.

Tags: , , ,

31 Responses:

  1. cd says:

    And I see that's the same thing that ensures that any images will only be visible to people who have a twitter account. Well, one way to cut down on bandwidth costs while improving social tracking data, I s'pose...

  2. You could use GET statuses/show/:id from Twitter's REST API. With include_entities=true the image URL will be included in the entities list. That API call doesn't need authentication, you can try it out with curl "", look for media_url.

    Regarding the iPhone app: huh. It still does have the image service setting. It's under Settings / Advanced / Image Service. I couldn't get any of the alternative services to work, though. What gives?

    • jwz says:

      Wow, what a pain in the ass!

      That works, though, thanks.

      I don't think "media_url" was present in there the last time I looked at that API.

      • John Kalucki says:

        The URL is returned with the Tweet markup upon post. Note that the TOS prohibits displaying the image without the containing Tweet, so there's rarely a reason to grab the URL unless rendering the entire Tweet anyway.

        • jwz says:


          Well, not that I would care about what the TOS says (I'm just a scofflaw like that) but my use cases are in fact totally within the TOS by happenstance. I do two things:

          A) Anything that @dnapizza or @dnalounge twits gets cross-posted to their respective Facebook pages and I want to include the twitted image (along with the text) as a thumb for that post (which would happen automagically if you had included <link> tags, but you don't) . (I can't use the Twitter Facebook app for this because it only works with "Users", not "Pages", so I have my own script.) And,

          B) I use a hacked version of the Twitter JS widget on that inlines the most recent twits, and I want the images to be thumbed there as well.

          FYI, I think the changes I made to that widget are generally-applicable, so feel free to grab my changes. Search for "jwz".

          • John Kalucki says:

            FWIW: The official Twitter integration cross-posts to Facebook accounts correctly, including inlining native images. I've no idea if it works with Pages or not. (I don't have a Facebook Page to verify.)

    • John Kalucki says:

      The problems with the other services are being worked on...

  3. Lionfire says:

    It looks like you can change the image service using the in-app settings: go to "accounts" (top left), then press "settings" (bottom left), then "advanced", and there should be "image service", which should let you use just about anything (via "custom").

  4. looks like base64...

    echo "Ab2uH0QCMAA0dCh=" |base64 -d - |xxd
    0000000: 01bd ae1f 4402 3000 3474 28 ....D.0.4t(


    Quite some similarity , but sadly close but not equal to the number.

  5. Neil says:

    What annoys me is that I can't zoom images any more. What a fuckup.

    Having said that, that I just had to type an email address into an input box on this page which doesn't disable autocapitalize and autocorrect, making it ten times harder, drives me crazy.

    We users are so demanding!

    • Skreidle says:

      I found that the Twitter/FB/OpenID buttons/text are sitting on top of the name/email/website boxes in the Droid 2's mobile presentation of this page..

    • jwz says:

      That is annoying... It looks like webkit supports autocorrect=off and autocapitalize=off on the input tag, but it doesn't look like there are CSS equivalents for that, making it more work to add it to the theme.

      • Neil says:

        Don't worry- the autocapitalize/autocorrect thing a pet peeve of mine. Every single "enter your email address" input needs the question asking. What is also a peeve is that people assume that it's just Apple throwing their weight around. I personally see it as more of a UI evolution just as we'll eventually have input elements that disallow voice to text dictation or whatever- hints to the computer about the expected content.

        I've no boner for HTML so I don't know the "correct" way this should have been implemented, but I've no doubt that if I ask 8 engineers I can get 8 different answers!

        Anyway, please don't take my whine personally. I'm just grisling. I should probably change my email address to autocapitalized dictionary words and never be bothered again.

      • Ryan Steele says:

        If you're going to go to the trouble of changing the HTML, the right thing to do would be to change the input tag to type="email", since that will prompt the client to bring up the optimized "email" keyboard with the "." and "@" keys, in addition to turning off autocorrect and autocapitalize.

  6. Skreidle says:

    Also: Hashbangs? Seriously? Why does Twitter hate us?

    • David M.A. says:

      The /#!/ nomenclature is, annoyingly enough, a standard google proposed to ensure that their crawler could properly parse a website that was encapsulated in those twelve layers of JavaScript and frames that Jamie is complaining about. It's extraordinarily stupid, yes, but I have a feeling we're going to see more and more of it -- Facebook and Klout are two other sites that use it that I can think of off the top of my head.

      • Brian Enigma says:

        So then, how does Google crawl it, for instance to pull the image into image search? Is there some out-of-band channel that lets them get at hashbang content, or is there some back door you can get at by setting your user agent to Googlebot?

      • Skreidle says:

        Io9/JezebelnKotaku/etc. used it for a month or so, caught serious hell for it, and took it back out..

      • How do you figure the hashbangs are a blight?

        • David M.A. says:

          I was about to say something snarky here, but then I realized you missed jamie by just that much.

        • jwz says:

          I am sad to discover that nobody has yet written the canonical "Hashbangs Considered Harmful" article so that I could just LMGTFY, but this is close:

          Tim Bray: Hash Blecch

          Before events took this bad turn, the contract represented by a link was simple: "Here’s a string, send it off to a server and the server will figure out what it identifies and send you back a representation." Now it’s along the lines of: "Here’s a string, save the hashbang, send the rest to the server, and rely on being able to run the code the server sends you to use the hashbang to generate the representation."

          Do I need to explain why this is less robust and flexible? This is what we call "tight coupling" and I thought that anyone with a Computer Science degree ought to have been taught to avoid it.

    • jwz says:

      This hashbang nonsense is a blight.

  7. Otto says:

    You can actually specify a different image service on the new Twitter iPhone App.

    Load it up, hit the "Accounts" button, then "Settings" in the bottom left. Then pick "Advanced", and "Image Service". Twitter's is the default, but all the others are still there too.