[英]FBChat and python can't send a simple message
所以我試圖用 fbchat 給自己發送一條消息,每次我都會出錯。
回溯(最近一次調用最后一次):
文件“main.py”,第 12 行,在
client.send(Message(text=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)
根據您的錯誤代碼,我假設您的代碼實際上是這樣的:
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
參數放在 Message 類中,而實際上它們是client.send()
函數的參數。 它應該看起來像這樣:
sent = client.send(Message(text=msg), thread_id="christopher.batey", thread_type=ThreadType.USER)
希望這能回答你的問題!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.