'请求'对象没有属性'方法'使用fbchat发送消息

时间:2016-09-14 22:01:28

标签: facebook python-3.x

我正在使用fbchat(版本0.40)创建消息传递机器人。我已经下载了所有依赖项(requestslxmlbeautifulsoup4),并且它们都是最新的。但是,由于我认为涉及请求模块的问题,我甚至无法使示例工作。 任何人都可以帮助我,告诉我为什么会出现这个错误以及如何解决它?

代码:

import fbchat

client = fbchat.Client(str(EMAIL_ADDRESS),str(PASSWORD))
friends = client.getUsers(str(FRIEND_NAME))
friend = friends[0]
sent = client.send(friend.uid, "Hey")
if sent:
    print("Message sent successfully!")
else:
    print("Message not sent")

(我已将我的密码和电子邮件地址更改为PASSWORD和EMAIL_ADDRESS以及朋友姓名中的FRIEND_NAME。)

错误讯息:

Traceback (most recent call last):
  File "<pyshell#41>", line 1, in <module>
    chat.send(friend.uid,"Hey")
  File "C:\Users\Algie\AppData\Local\Programs\Python\Python35-32\lib\site-packages\fbchat\client.py", line 245, in send
    r = self._post(SendURL, data)
  File "C:\Users\Algie\AppData\Local\Programs\Python\Python35-32\lib\site-packages\fbchat\client.py", line 116, in _post
    return self._session.post(url, headers=self._header, data=payload, timeout=timeout)
  File "C:\Users\Algie\AppData\Local\Programs\Python\Python35-32\lib\site-packages\requests\sessions.py", line 522, in post
    return self.request('POST', url, data=data, json=json, **kwargs)
  File "C:\Users\Algie\AppData\Local\Programs\Python\Python35-32\lib\site-packages\requests\sessions.py", line 459, in request
    hooks = hooks,
  File "C:\Users\Algie\AppData\Local\Programs\Python\Python35-32\lib\site-packages\requests\models.py", line 215, in __init__
    data = [] if data is None else data
  File "C:\Users\Algie\AppData\Local\Programs\Python\Python35-32\lib\site-packages\requests\models.py", line 215, in __init__
    data = [] if data is None else data
  File "C:\Users\Algie\AppData\Local\Programs\Python\Python35-32\lib\bdb.py", line 48, in trace_dispatch
    return self.dispatch_line(frame)
  File "C:\Users\Algie\AppData\Local\Programs\Python\Python35-32\lib\bdb.py", line 66, in dispatch_line
    self.user_line(frame)
  File "C:\Users\Algie\AppData\Local\Programs\Python\Python35-32\lib\idlelib\Debugger.py", line 21, in user_line
    self.gui.interaction(message, frame)
AttributeError: 'Request' object has no attribute 'method'

另外:如果有帮助,我可以发布我的模块文件夹。

0 个答案:

没有答案