Skip to content

Instantly share code, notes, and snippets.

graph_url = 'https://graph.facebook.com/v15.0/'
def func_get_business_account_deatils(search_id='',instagram_account_id='',access_token=''):
url = graph_url + instagram_account_id
param = dict()
param['fields'] = 'business_discovery.username('+search_id + \
'){followers_count,follows_count,name,biography,username,profile_picture_url,id, media_count,media{comments_count,like_count,media_url,permalink,user_name,caption,timestamp,media_type,media_product_type}}'
param['access_token'] = access_token
response = requests.get(url,params=param)
response =response.json()
return response
graph_url = 'https://graph.facebook.com/v15.0/'
def status_of_upload(ig_container_id = '',access_token=''):
url = graph_url + ig_container_id
param = {}
param['access_token'] = access_token
param['fields'] = 'status_code'
response = requests.get(url,params=param)
response = response.json()
return response
graph_url = 'https://graph.facebook.com/v15.0/'
def post_video(video_url='',caption='',instagram_account_id='',access_token=''):
url = graph_url + instagram_account_id + '/media'
param = dict()
param['access_token'] = access_token
param['caption'] = caption
param['video_url'] = video_url
param['media_type'] = 'VIDEO'
param['thumb_offset'] = '10'
response = requests.post(url, params=param)
graph_url = 'https://graph.facebook.com/v15.0/'
def post_carousel(caption = '',media_url = '',instagram_account_id='',access_token=''):
url = graph_url + instagram_account_id + '/media'
param = dict()
param['access_token'] = access_token
param['is_carousel_item'] = 'true'
container_id = []
for i in media_url:
param['image_url'] = i
response = requests.post(url, params=param)
graph_url = 'https://graph.facebook.com/v15.0/'
# creation_id is container_id
def publish_container(creation_id = '',instagram_account_id='',access_token=''):
url = graph_url + instagram_account_id + '/media_publish'
param = dict()
param['access_token'] = access_token
param['creation_id'] = creation_id
response = requests.post(url,params=param)
response = response.json()
return response
graph_url = 'https://graph.facebook.com/v15.0/'
def post_image(caption='', image_url='',instagram_account_id='',access_token=''):
url = graph_url + instagram_account_id + '/media'
param = dict()
param['access_token'] = access_token
param['caption'] = caption
param['image_url'] = image_url
response = requests.post(url, params=param)
response = response.json()
return response
graph_url = 'https://graph.facebook.com/v15.0/'
def publish_container(creation_id = '',access_token = '',instagram_account_id=''):
url = graph_url + instagram_account_id + '/media_publish'
param = dict()
param['access_token'] = access_token
param['creation_id'] = creation_id
response = requests.post(url,params=param)
response = response.json()
return response
graph_url = 'https://graph.facebook.com/v15.0/'
def status_of_upload(ig_container_id = '',access_token=''):
url = graph_url + ig_container_id
param = {}
param['access_token'] = access_token
param['fields'] = 'status_code'
response = requests.get(url,params=param)
response = response.json()
return response
graph_url = 'https://graph.facebook.com/v15.0/'
def post_reel(caption='', media_type ='',share_to_feed='',thumb_offset='',video_url='',access_token = '',instagram_account_id):
url = config.graph_url + instagram_account_id + '/media'
param = dict()
param['access_token'] = access_token
param['caption'] = caption
param['media_type'] = media_type
param['share_to_feed'] = share_to_feed
param['thumb_offset'] = thumb_offset
param['video_url'] = video_url
graph_url = 'https://graph.facebook.com/v15.0/'
def get_comment(comment = '',access_token='',media_data=''):
media_id = media_data['data'][-1]['id']
url = graph_url + media_id +'/comments'
param = dict()
param['message'] = comment
param['access_token'] = access_token
response = requests.post(url,params=param)
response = response.json()
return response