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

cannot send messages to valid groups or pages #363

Closed navneethnarendra closed 5 years ago

navneethnarendra commented 5 years ago

Description of the problem

cannot send messages to valid groups or pages

Code to reproduce

running the script as below

Example code

# -*- coding: utf-8 -*-
from fbchat import Client
from fbchat.models import *

client = Client(<id>, <pwd>)
client.send(Message(<text>), thread_id=<groupId>, thread_type=ThreadType.GROUP)
client.logout()

Traceback

Traceback (most recent call last):
***********
    client.send(Message(text='5$GROUP: it worked really boy !!!!!'), thread_id='1014925294', thread_type=ThreadType.GROUP)

  File "/usr/local/lib/python2.7/site-packages/fbchat/client.py", line 1093, in send

    return self._doSendRequest(data)

  File "/usr/local/lib/python2.7/site-packages/fbchat/client.py", line 1060, in _doSendRequest

    j = self._post(self.req_url.SEND, data, fix_request=True, as_json=True)

  File "/usr/local/lib/python2.7/site-packages/fbchat/client.py", line 136, in _post

    raise e

fbchat.models.FBchatFacebookError: Error when sending request: Got 500 response

***********

Traceback (most recent call last):

    client.send(Message(text='5$GROUP: it worked really boy !!!!!'), thread_id='381019862395392', thread_type=ThreadType.GROUP)

  File "/usr/local/lib/python2.7/site-packages/fbchat/client.py", line 1093, in send

    return self._doSendRequest(data)

  File "/usr/local/lib/python2.7/site-packages/fbchat/client.py", line 1060, in _doSendRequest

    j = self._post(self.req_url.SEND, data, fix_request=True, as_json=True)

  File "/usr/local/lib/python2.7/site-packages/fbchat/client.py", line 136, in _post

    raise e

fbchat.models.FBchatFacebookError: Error #1545012 when sending request: There was a temporary error, please try again.

Environment information

madsmtm commented 5 years ago

Can you try running with debug information enabled, and then giving some of that output? (make sure to remove all personal data)

# -*- coding: utf-8 -*-
from fbchat import Client
from fbchat.models import *
import logging

logging.basicConfig(level=logging.DEBUG)

client = Client(<id>, <pwd>, logging_level=logging.DEBUG)
client.send(Message(<text>), thread_id=<groupId>, thread_type=ThreadType.GROUP)
client.logout()

And is it possible for you to try running on another python version (e.g. Python 3.7)?

navneethnarendra commented 5 years ago

it worked by swapping to ThreadType.PAGE Thanks though for your quick response @madsmtm