无法在 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 向我的一个联系人发送了一条消息,但后来我在空闲时得到了它。有人可以解决这个问题吗?
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)
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 向我的一个联系人发送了一条消息,但后来我在空闲时得到了它。有人可以解决这个问题吗?
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)