Skip to content

Instantly share code, notes, and snippets.

@jkishner
Last active August 3, 2016 04:59
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jkishner/28f539d04d2e32c755d2 to your computer and use it in GitHub Desktop.
Save jkishner/28f539d04d2e32c755d2 to your computer and use it in GitHub Desktop.
instagramImage.py
import requests
import json
import sys
import urllib
import webbrowser
url = sys.argv[1]
data = requests.request('GET','http://api.instagram.com/publicapi/oembed/?url=' + url)
if data.status_code == 200:
embed = json.loads(data.text)
img = embed['thumbnail_url']
img2 = urllib.quote(img, '')
mid = 'instagram://media?id=' + embed['media_id']
mid2 = urllib.quote(mid, '')
webbrowser.open('drafts://x-callback-url/create?text=' + img2 + '%0A%0A' + mid2)
@thulsey
Copy link

thulsey commented Aug 3, 2016

Thanks, exactly what I had been looking for.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment