簡體   English   中英

無法在python上使用fbchat發送消息

[英]Cannot send messages using fbchat on python

from fbchat import Client
from fbchat.models import *

client = Client('<username>', '<password>')

print('Own id: {}'.format(client.uid))

client.send(Message(text='Hi me!'), thread_id='clientname', thread_type=ThreadType.USER)

client.logout()

上面的代碼示例是我從在線教程中獲得的,該程序能夠登錄Facebook Messenger,並告訴我我的用戶ID。 然后,我添加了一個client.send,以查看它是否實際上使用facebook Messenger向我的一個聯系人發送了一條消息,但隨后我在IDLE中得到了它。 有人可以提供解決方案嗎?

    Traceback (most recent call last):
  File "C:/Users/User/Desktop/Python/fbchat trial.py", line 10, in <module>
    client.send(Message(text='Hi me!'), thread_id='User', thread_type=ThreadType.USER)
  File "C:\Users\User\AppData\Local\Programs\Python\Python36\lib\site-packages\fbchat\client.py", line 955, in send
    return self._doSendRequest(data)
  File "C:\Users\User\AppData\Local\Programs\Python\Python36\lib\site-packages\fbchat\client.py", line 923, in _doSendRequest
    j = self._post(self.req_url.SEND, data, fix_request=True, as_json=True)
  File "C:\Users\User\AppData\Local\Programs\Python\Python36\lib\site-packages\fbchat\client.py", line 128, in _post
    raise e
  File "C:\Users\User\AppData\Local\Programs\Python\Python36\lib\site-packages\fbchat\client.py", line 124, in _post
    return check_request(r, as_json=as_json)
  File "C:\Users\User\AppData\Local\Programs\Python\Python36\lib\site-packages\fbchat\utils.py", line 193, in check_request
    raise FBchatFacebookError('Error when sending request: Got {} response'.format(r.status_code), request_status_code=r.status_code)
fbchat.models.FBchatFacebookError: Error when sending request: Got 500 response

您可能需要嘗試一下。 我認為您的thread_id錯誤。

client.send(Message(text='Hi me!'), thread_id=client.uid, thread_type=ThreadType.USER)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM