I have been trying to use the Instagram API with python. After getting valid access_token, client_id, client_secret, I have tried to use the function user_recent_media.
access_token -
access_token, user_info = unauthenticated_api.exchange_code_for_access_token(code)
setting connection
api = client.InstagramAPI(access_token=access_token, client_secret=client_secret)
The connection is established successfully and then I wanted to get the user_recent media:
recent_media, next = api.user_recent_media(user_id = user_info['id'], count = 10)
Then I get the following error:
Traceback (most recent call last):
File "C:/instagram/main.py", line 57, in <module>
recent_media, next = api.user_recent_media(user_id = user_info['id'], count = 10)
File "C:\Users\user-pc\Anaconda\lib\site-packages\instagram\bind.py", line 197, in _call
return method.execute()
File "C:\Users\user-pc\Anaconda\lib\site-packages\instagram\bind.py", line 189, in execute
content, next = self._do_api_request(url, method, body, headers)
File "C:\Users\user-pc\Anaconda\lib\site-packages\instagram\bind.py", line 151, in _do_api_request
obj = self.root_class.object_from_dictionary(entry)
File "C:\Users\user-pc\Anaconda\lib\site-packages\instagram\models.py", line 99, in object_from_dictionary
for comment in entry['comments']['data']:
KeyError: 'data'
Someone knows what is the problem? I have checked everywhere and couldn't find the reason for this error.