因此,我尝试通过fbchat向自己发送消息,并且每次我得到错误消息。
回溯(最近通话最近一次):
中的文件“ main.py”,第12行
client.send(Message(text(ms = msg,thread_id =“ christopher.batey”,thread_type = ThreadType.USER))
TypeError: init ()获得了意外的关键字参数'thread_id'
我要拔头发了。我从fbchat文档中获取ThreadType,无法解决此错误。
我的代码如下:
from fbchat import Client
from fbchat.models import *
client = Client(my_user, my_pass)
name = "christopher.batey"
friends = client.searchForUsers(name)
friend = friends[0]
uid = friend.uid
msg = "This is a test"
sent = client.send(msg, thread_id=uid, thread_type=ThreadType.USER)
答案 0 :(得分:0)
根据您的错误代码,我假设您的代码实际上是这样的:
from fbchat import Client
from fbchat.models import *
client = Client(my_user, my_pass)
name = "christopher.batey"
friends = client.searchForUsers(name)
friend = friends[0]
uid = friend.uid
msg = "This is a test"
sent = client.send(Message(text=msg, thread_id="christopher.batey", thread_type=ThreadType.USER))
最后一部分看起来是将thread_id
和thread_type
自变量实际上是client.send()
函数的自变量放在Message类中。它应该看起来像这样:
sent = client.send(Message(text=msg), thread_id="christopher.batey", thread_type=ThreadType.USER)
希望能回答您的问题!