From 64b9624563d64cd7c1cc71d4981428c0168ce4dd Mon Sep 17 00:00:00 2001 From: "Bankde@hotmail.com" Date: Thu, 2 Feb 2017 23:07:09 +0700 Subject: [PATCH 1/2] fix listening encoding --- fbchat/client.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fbchat/client.py b/fbchat/client.py index 18fbe3e..d00dd09 100644 --- a/fbchat/client.py +++ b/fbchat/client.py @@ -44,6 +44,7 @@ UserInfoURL ="https://www.facebook.com/chat/user_info/" ConnectURL ="https://www.facebook.com/ajax/add_friend/action.php?dpr=1" RemoveUserURL="https://www.facebook.com/chat/remove_participants/" LogoutURL ="https://www.facebook.com/logout.php" +facebookEncoding = 'UTF-8' # Log settings log = logging.getLogger("client") @@ -564,6 +565,7 @@ class Client(object): } r = self._get(StickyURL, data) + r.encoding = facebookEncoding j = get_json(r.text) self.seq = j.get('seq', '0') From fc977c4fa095e1f8b90fbd3e6127864cc5de0d23 Mon Sep 17 00:00:00 2001 From: "Bankde@hotmail.com" Date: Thu, 2 Feb 2017 23:50:41 +0700 Subject: [PATCH 2/2] change UTF-8 to global constant --- fbchat/client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fbchat/client.py b/fbchat/client.py index d00dd09..163560f 100644 --- a/fbchat/client.py +++ b/fbchat/client.py @@ -376,7 +376,7 @@ class Client(object): """ r = self._postFile(UploadURL, image) if isinstance(r._content, str) is False: - r._content = r._content.decode("utf-8") + r._content = r._content.decode(facebookEncoding) # Strip the start and parse out the returned image_id return json.loads(r._content[9:])['payload']['metadata'][0]['image_id']