Last active
September 30, 2022 17:45
-
-
Save ritik1009/4d171fcc846f8b6cf9c8ef6f5edceca5 to your computer and use it in GitHub Desktop.
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
def get_post_insights(access_token = '',api_url = '',instagram_account_id = ''): | |
url = api_url + instagram_account_id + '/media' | |
param = dict() | |
param['access_token'] = access_token | |
response = requests.get(url=url, params=param) | |
response = response.json() | |
media_insights = [] | |
for i in response['data']: | |
url = api_url + i + '/insights' | |
param = dict() | |
param['access_token'] = access_token | |
param['metric'] = 'engagement,impression,reach,saved,video_views' | |
response = requests.get(url=url,params=param) | |
print("\n response",response) | |
response = response.json() | |
print("\n response",response) | |
media_insights.append(response) | |
return media_insights |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment