0
當我運行的代碼,它的工作原理沒有錯誤,但我注意到,它確實沒有登錄到Facebook併發布一篇文章,說「你好世界」 。一旦登錄,永遠不會。 我使用圖形API。試圖登錄到Facebook,但它沒有得到
想得到一些幫助。謝謝
import urllib2, cookielib, re, os, sys
from facepy import GraphAPI
import facebook
class Facebook:
def __init__(self, email, password):
self.email = email
self.password = password
cj = cookielib.CookieJar()
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
opener.add_headers = [('Referer', 'http://login.facebook.com/login.php'),
('Content-Type', 'application/x-www-form-urlencoded'),
('User-Agent', 'Mozilla/8.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.7'),
'Gecko/20091221 Firefox/3.5.7 (.NET CLR 3.5.30729)']
self.opener = opener
def login(self):
url = 'https://login.facebook.com/login.php'
data = "locale=en_US&non_com_login=&email=" + self.email + "&pass="+ self.password + "&lsd=20TOl"
usock = self.opener.open('https://www.facebook.com/')
usock = self.opener.open(url, data)
read = usock.read()
if "Logout" in read:
print "Logged in."
graph = facebook.GraphAPI(Access Token)
graph.put_object("me", "feed", post="Hello, World!")
else:
print "failed login"
print read
sys.exit()
print read
f = Facebook("email", "password")
f.login()
nik = graph.fql('select uid, name, friends from user where uid in'
'(select first_name, middle_name, last_name '
'from friend where uid1 = me())')
print nik
您的問題不包括問題。給出一個[mcve]和一個比*「it failed」*更好的問題描述。 – jonrsharpe
@jonrsharpe謝謝 – user3225609