Last active
August 3, 2016 04:59
-
-
Save jkishner/28f539d04d2e32c755d2 to your computer and use it in GitHub Desktop.
instagramImage.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks, exactly what I had been looking for.