2017-04-06 1 views
0

Also ich versuche Instagram Fotos zu bekommen, die bestimmte Parameter passen, und ich erhalte die folgenden Stapel:python-instagram OAuthPermissionsException

Traceback (most recent call last): 
    File "instagram_find_shows.py", line 83, in <module> 
    if __name__ == "__main__": main() 
    File "instagram_find_shows.py", line 48, in main 
    get_instagram_posts(show_name, show_time, coordinates) 
    File "instagram_find_shows.py", line 73, in get_instagram_posts 
    str(coordinates[1]), min_time, max_time) 
    File "C:\Users\User Name\Anaconda3\lib\site-packages\instagram\bind.py", line 197, in _call 
    return method.execute() 
    File "C:\Users\User Name\Anaconda3\lib\site-packages\instagram\bind.py", line 189, in execute 
    content, next = self._do_api_request(url, method, body, headers) 
    File "C:\Users\User Name\Anaconda3\lib\site-packages\instagram\bind.py", line 163, in _do_api_request 
    raise InstagramAPIError(status_code, content_obj['meta']['error_type'], content_obj['meta']['error_message']) 
instagram.bind.InstagramAPIError: (400) OAuthPermissionsException-This request requires scope=public_content, but this access token is not authorized with this scope. The user must re-authorize your application with scope=public_content to be granted this permissions. 

Der Code ist wie folgt:

def get_instagram_posts(name, time, coordinates): 
    max_time_dt = time + timedelta(hours=3) 
    min_time_dt = time - timedelta(hours=1) 

    max_time = str(calendar.timegm(max_time_dt.timetuple())) 
    min_time = str(calendar.timegm(min_time_dt.timetuple())) 

    dist_rad_str = str(insta_dist_radius_m) 
    count_str = str(insta_count) 

    api = InstagramAPI(access_token=insta_access_token, 
     client_secret=insta_client_secret) 

    r = api.media_search(name, count_str, str(coordinates[0]), 
     str(coordinates[1]), min_time, max_time) 

    photos = [] 

    for media in r: 
     photos.append('<img src="%s"/>' % media.images['thumbnail'].url) 

    print(photos[0]) 

I kann nicht herausfinden, was zu tun ist ... Wörtlich versuche ich nur, einen einfachen Test zu machen, nicht zu versuchen, ihre API zu verkrüppeln. Gibt es eine Möglichkeit, dies innerhalb der Parameter von Instagram zu tun? Vielen Dank!

Antwort

0

behoben, indem Sie im Browser die folgende URL aufrufen:

https://www.instagram.com/oauth/authorize?client_id=[CLIENT_ID]&redirect_uri=[REDIRECT_URI]&response_type=code&scope=basic+public_content+follower_list+comments+relationships+likes