Encoding issues
See original GitHub issueHi,
I recently implemented the bot example using django. However the fb send api returned an error of internal failure related to oauth.
{"error":{"message":"(#-1) Send API unexpected internal error","type":"OAuthException","code":-1,"error_subcode":2018012,"fbtrace_id":"BZ8p\/q9haBY"}}
The problem is related to the message object ,as you might read, text must be UTF-8 encoded and less than 640char.
All the library is beautifully written and respects UNICODE, however text must be encoded as follows:
page.send(sender_id,message.encode('utf-8'))
so that it can reliably echo back text messages.
If you agree I can make a pull request modifying Page.send(…) such that
text = message if isinstance(message, str) else None
is changed for
text = message if isinstance(message, str) else message.encode('utf-8') if isinstance(message,unicode) else None
This will allow it to support unicode strings and respect facebook´s api.
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (3 by maintainers)
Top GitHub Comments
Thank you all. fixed
Thanks merged.