Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

client.getUsers("FRIEND'S NAME") doesn't work #37

Closed
hman190 opened this issue Apr 2, 2016 · 3 comments
Closed

client.getUsers("FRIEND'S NAME") doesn't work #37

hman190 opened this issue Apr 2, 2016 · 3 comments

Comments

@hman190
Copy link

hman190 commented Apr 2, 2016

Hi,
I used the example from README, but it doesn't work at all. Can you give me some advices? My code is as follows:

import fbchat
client = fbchat.Client("MY_ID", "MY_PASSWORD")
friends = client.getUsers("Ning")  # I tried a friend's name
friend = friends[0]

After executing the code, it shows the following error messages:

friends = client.getUsers('Ning')
File "build/bdist.linux-x86_64/egg/fbchat/client.py", line 189, in getUsers
File "build/bdist.linux-x86_64/egg/fbchat/utils.py", line 18, in get_json
File "/usr/lib/python2.7/json/__init__.py", line 338, in loads
return _default_decoder.decode(s)
File "/usr/lib/python2.7/json/decoder.py", line 366, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib/python2.7/json/decoder.py", line 382, in raw_decode
obj, end = self.scan_once(s, idx)
ValueError: Expecting ',' delimiter: line 1 column 63 (char 62)

Thanks!

@hman190 hman190 changed the title client.getUsers('"FRIEND'S NAME"') doesn't work client.getUsers("FRIEND'S NAME") doesn't work Apr 2, 2016
@PidgeyL
Copy link
Collaborator

PidgeyL commented Apr 4, 2016

Judging from the name, I guess your response data might contain non-ascii chars, am I correct?

@afonsocarlos
Copy link
Contributor

Download the repo on your computer, then edit utils.py file. Try to change get_json(text) function from this: return json.loads(re.sub(r"for.*(.*;.*;.*).*;", '', text.encode('utf-8').decode("unicode-escape"), 1)) to this: return json.loads(re.sub(r"^[^{]*", '', text, 1)). Save the file and install fbchat again via setup.py from the folder you've downloaded.

code by @HashirZahir on pull request #32

@neilyueh
Copy link

neilyueh commented Apr 8, 2016

thanks. return json.loads(re.sub(r"^[^{]*", '', text, 1))
fix the issue for me.

@madsmtm madsmtm closed this as completed May 10, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants