fbchat-dev / fbchat

Facebook Chat (Messenger) for Python
https://fbchat.readthedocs.io
BSD 3-Clause "New" or "Revised" License
1.19k stars 412 forks source link

client.sendLocalImage() Failes at client.py:513 #117

Closed Torxed closed 7 years ago

Torxed commented 7 years ago

Sending a private conversation creates the same problem.

Traceback (most recent call last):
  File "fb.py", line 15, in <module>
    client.sendLocalImage('group_conversation_id', message='duty_calls.png',image='duty_calls.png') # send local image
  File "/usr/lib/python3.6/site-packages/fbchat-0.7.1-py3.6.egg/fbchat/client.py", line 501, in sendLocalImage
  File "/usr/lib/python3.6/site-packages/fbchat-0.7.1-py3.6.egg/fbchat/client.py", line 513, in uploadImage
  File "/usr/lib/python3.6/json/__init__.py", line 354, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.6/json/decoder.py", line 339, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.6/json/decoder.py", line 357, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
JohnathonNow commented 7 years ago

I am having trouble reproducing this, are there any more details you can provide?

Torxed commented 7 years ago
import fbchat

client = fbchat.Client(None, None, debug=False, do_login=False)
client.loadSession('fb.sesh')

friends = client.getUsers("Friends name")
friend = friends[0]
print(friend) # Verify user_id is the correct one, and it is

client.sendLocalImage(friend.uid, message='duty_calls.png', image='duty_calls.png') # send local image # Raises the exception
Torxed commented 7 years ago

What fails is:

jobj = json.loads(r._content[9:])

_content being a string of nothing, that is "".

Basically something in postFile() returns "" to uploadImage().

Torxed commented 7 years ago
[torxed@sidekick ~]$ file duty_calls.png 
duty_calls.png: PNG image data, 300 x 330, 8-bit grayscale, non-interlaced
madsmtm commented 7 years ago

Maybe you could provide us with the actual image (Though I do appreciate your file output)

madsmtm commented 7 years ago

Could you perhaps try this in v. 1.0.x? ;)