Closed jdrh0503 closed 7 years ago
Hi, I solved this problem with small workaround ;)
payload = { 'recipient': str({'id': sid}), 'message': str({'attachment': {'type': "image", 'payload': {}}}), 'filedata': (filename, open(filename, 'rb'), 'image/png') }
multipart_data = MultipartEncoder(payload) multipart_header = {'Content-Type': multipart_data.content_type}
requests.post( 'https://graph.facebook.com/v2.6/me/messages', data=multipart_data, params={'access_token': THE_TOKEN}, headers=multipart_header).json()
Can you add verify this and fix a bug?
Are you using Python 2? And can you explain the fix (or make a PR)?
Hi, I have tried to send images from a local directory and it looks like an error in the function
def send_attachment(self, recipient_id, attachment_type, attachment_path, notification_type=NotificationType.regular):
The error that appears is:
send_attachment 'payload': {} TypeError: unhashable type: 'dict'
I think the problem is in the double keys in which they are found in 'recipient' and 'message'
'recipient': {{ 'id': recipient_id }}, 'notification_type': notification_type, 'message': {{ 'attachment': { 'type': attachment_type, 'payload': {} } }},
Maybe with what I've seen can be corrected. Thank you.