def send_image_local(recipient_id, image_path):
data = {
'recipient': str({
'id': recipient_id
}),
'message': str({
'attachment': {
'type': 'image',
'payload': {
}
}
}),
'filedata': (os.path.basename(image_path), open(image_path, 'rb'),
'image/png')
}
data = MultipartEncoder(data)
params = {
'access_token': os.environ["PAGE_ACCESS_TOKEN"]
}
headers = {
'Content-Type': data.content_type
}
r = requests.post("https://graph.facebook.com/v2.6/me/messages",
params=params, headers=headers, data=data).json()
评论列表
文章目录