Skip to content

Instantly share code, notes, and snippets.

@satojkovic
Created October 2, 2012 16:46
Show Gist options
  • Save satojkovic/3820994 to your computer and use it in GitHub Desktop.
Save satojkovic/3820994 to your computer and use it in GitHub Desktop.
instagram python library sample
import bottle
from bottle import route, post, run, request
from instagram import client, subscriptions
bottle.debug(True)
CONFIG = {
'client_id': ''
'client_secret': ''
'redirect_uri': 'http://localhost:8515/oauth_callback'
}
unauthenticated_api = client.InstagramAPI(**CONFIG)
def process_tag_update(update):
print update
reactor = subscriptions.SubscriptionsReactor()
reactor.register_callback(subscriptions.SubscriptionType.TAG, process_tag_update)
@route('/')
def home():
try:
url = unauthenticated_api.get_authorize_url(scope=["likes","comments"])
return '<a href="%s">Connect with Instagram</a>' % url
except Exception, e:
print e
@route('/oauth_callback')
def on_callback():
code = request.GET.get("code")
if not code:
return 'Missing code'
try:
access_token = unauthenticated_api.exchange_code_for_access_token(code)
if not access_token:
return 'Could not get access token'
print(access_token)
except Exception, e:
print e
run(host='localhost', port=8515, reloader=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment