-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget_content.py
47 lines (32 loc) · 1.61 KB
/
get_content.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import pprint
from utils import *
def get_business_discovery(params):
endpoint_params = dict()
endpoint_params['access_token'] = params['access_token']
url = params['endpoint_base'] + \
params['instagram_account_id']
endpoint_params['fields'] = f"business_discovery.username({params['id']}){'{followers_count,media_count, media{permalink, comments_count, like_count}}'}"
return make_api_call(url, endpoint_params)
def get_user_media(params):
endpoint_params = dict()
endpoint_params['access_token'] = params['access_token']
url = params['endpoint_base'] + \
params['instagram_account_id']
endpoint_params['fields'] = f"business_discovery.username({params['id']}){'{media{permalink,media_url,caption,media_type,comments_count, like_count}}'}"
return make_api_call(url, endpoint_params)
def get_media_details(params):
for post in get_user_media(params)['business_discovery']['media']['data']:
if post['permalink'] == params["permalink"]:
return post
def get_user_data(params):
endpoint_params = dict()
endpoint_params['access_token'] = params['access_token']
url = params['endpoint_base'] + \
params['instagram_account_id']
endpoint_params['fields'] = f"business_discovery.username({params['id']}){'{biography ,id,ig_id, followers_count, follows_count, media_count, name, profile_picture_url, username, website}'}"
return make_api_call(url, endpoint_params)
# params = get_creds()
# params['id'] = 'bluebottle'
# params['media_id'] = "17895229742362082"
# pp = pprint.PrettyPrinter(indent=2)
# pp.pprint(get_user_media(params))