只是想用python发送一条Facebook消息。你知道吗
代码:
import fbchat
from fbchat import Client
from fbchat.models import *
client = Client("my_username", "my_password")
#help(fb.Client.send)
#client.send(text="This is a test", thread_id="christopher.batey", thread_type=ThreadType.USER)
name = "christopher.batey"
friends = client.searchForUsers(name)
friend = friends[0]
uid = friend.uid
msg = "This is a test"
print(help(client.send))
client.send(Message(text=msg, thread_id="christopher.batey", thread_type=ThreadType.USER))
错误:
Traceback (most recent call last):
File "main.py", line 13, in
client.send(Message(text=msg, thread_id="christopher.batey", thread_type=ThreadType.USER))
TypeError: init() got an unexpected keyword argument 'thread_id'
我不熟悉API,但从文档来看,正确的调用应该是:
其中message对象是传入send的第一个参数,后跟thread\u id和thread\u type。你知道吗
几年前我花了一些时间探索这个模块。你知道吗
快速回顾github示例,线程id应该是一个数字。你知道吗
这样的变化
至
在你的代码里。因为你的uid也是你要发送的朋友的。你知道吗
相关问题 更多 >
编程相关推荐