I’m writing a java program that goes out and searches twitter, finds certain instagram links, and then downloads the instagram image to a directory. I’ve written all of the code to do the twitter searching and image saving but the problem that I’m having is that I get a URL in the following format
http://t.co/xxxxxxxx
From the twitter search which then if followed resolves to an instagram URL such as
http://instagr.am/p/xxxxxxxxxx/
How can I go about resolving the original URL to the instagram URL and then downloading the appropriate image on that page?
Instagram provides an API call for this. It returns everything you would need in JSON format just provide the short URL like:
http://api.instagram.com/oembed?url=http://instagr.am/p/XXXXXX/
And you’ll get the data like this:
Or if all you want is the image you can just add a /media to the URL:
http://instagr.am/p/XXXXXX/media