Python 3.x Python Facebookchat AttributeError';str';对象没有属性'_发送数据';

Python 3.x Python Facebookchat AttributeError';str';对象没有属性'_发送数据';,python-3.x,Python 3.x,我正在尝试使用python向我的朋友发送消息。 但我得到了这个错误 sent = client.send(friend.uid, msg) File "/home/can/anaconda3/lib/python3.7/site-packages/fbchat/_client.py", line 1059, in send data.update(message._to_send_data()) AttributeError: 'str' object has no attri

我正在尝试使用python向我的朋友发送消息。 但我得到了这个错误

   sent = client.send(friend.uid, msg)
  File "/home/can/anaconda3/lib/python3.7/site-packages/fbchat/_client.py", line 1059, in send
    data.update(message._to_send_data())
AttributeError: 'str' object has no attribute '_to_send_data'
我可以登录到我的帐户,ı可以输入朋友的价值,也可以输入我的朋友姓名

然后,当ı写我的消息时,例如“hello”,然后按enter键,它会给我错误信息

程序代码

import fbchat
from getpass import getpass
username = str(input("Username: "))
client = fbchat.Client(username, getpass())
no_of_friends = int(input("Number of friends: "))
for i in range(no_of_friends):
    name = str(input("Name: "))
    friends = client.searchForUsers(name)  # return a list of names
    friend = friends[0]
    msg = str(input("Message: "))
    sent = client.send(friend.uid, msg)
    if sent:
        print("Message sent successfully!")
我可以看到“消息已成功发送!”此消息吗?此外,模块也已成功安装


我正在使用Ubuntu 19.10

我自己解决问题。ı把答案放在这里,也许有人会有同样的错误,可以在这里找到答案

我的错误在这里

sent = client.send(friend.uid, msg)
我就这样变了,

sent = client.sendMessage(msg, thread_id=friend.uid)
成功了