vendredi 11 novembre 2016

Get an access token from Instagram API WITHOUT a browser?

I'm working on a project where I pull in data from social media according to certain queries and analyze them. Currently I'm working on pulling in Instagram media data. The only thing I want to do is to input a query and get JSON media/likes/comments.... I read the documentation of their API. I found that I couldn't get an access token without authorizing using my own account in a browser. I know there's gotta be a user, so I assume using my own account is fine. But the problem is that I don't want to get an access token manually from a browser.

Currently I'm hardcoding the access token. It will expire and I have to update it manually every time. I bet there's a better solution. Could someone help me out? Thanks.

class instagramFeed():

CLIENT_ID = "MY-APP-ID" 
REDIRECT_URI = "MY-ORGANIZATIONS-URI"
ACCESS_TOKEN = "I MANUALLY GENERATE THIS TOKEN"
query = None

def __init__(self):
    None

def get_data(self, query):
    response = urllib2.urlopen("http://ift.tt/2fILxVm"+query+"&access_token="+self.ACCESS_TOKEN)




Aucun commentaire:

Enregistrer un commentaire