问题
I am currently trying to use fbchat (https://github.com/carpedm20/fbchat) to build a small FB-Bot, but I can not login with fbchat.
I took the code directly from the examples, but when I try to login it fails. In Facebook I do get the message, that someone with an unknown browser tried to login - I accept this message ("This was me") but it is shown everytime I try to login via the script. Username and Password are correct.
import fbchat
client = fbchat.Client("123456789", "987654321")
friends = client.getUsers("FRIEND'S NAME") # return a list of names
Any ideas?
Thank you
回答1:
Are you running the code on a vps or from an IP address different than the one that you usually use to log in to your Facebook account?
If so, try SSH tunneling through that IP address, and login to Facebook with a browser.
The point is, you need to login to Facebook with a browser from that IP address. There are some verification steps that can only be done with a browser. FB will also ask you to change your password, follow through and do it. Then, your code should be good to go. You might have to do this again after a few hours if your client disconnects, but after 3-4 times, FB will acknowledge the new IP address as "safe" and you'll be all set.
来源:https://stackoverflow.com/questions/41399539/python-fbchat-login-failed