本文整理匯總了Python中pyfb.Pyfb.authenticate方法的典型用法代碼示例。如果您正苦於以下問題:Python Pyfb.authenticate方法的具體用法?Python Pyfb.authenticate怎麽用?Python Pyfb.authenticate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pyfb.Pyfb
的用法示例。
在下文中一共展示了Pyfb.authenticate方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: get
# 需要導入模塊: from pyfb import Pyfb [as 別名]
# 或者: from pyfb.Pyfb import authenticate [as 別名]
def get(self, user_token):
#return {User_data: User[token]}
FACEBOOK_APP_ID = '134416106741047'
facebook = Pyfb(FACEBOOK_APP_ID)
#Opens a new browser tab instance and authenticates with the facebook API
#It redirects to an url like http://www.facebook.com/connect/login_success.html#access_token=[access_token]&expires_in=0
facebook.authenticate()
#Copy the [access_token] and enter it below
getToken = user_token#'CAACEdEose0cBACIgotCQGDecYsWW1O7wrc5saw0ZCxrM8nKzF3wWgIvQqGyb9H5u3MIBKak9jcYc3l1CNZCdYniVI3tweTC8vX2PdibMlJrdrH1LIeJnmgWQS8WpkXyRzY8dpvGgFDZARq2amdAZBEXEXJePKSuMqTIOXCCfQMzNd3QMtldxD25lkFg3IANRVfjviSo6uQZDZD'
#Sets the authentication token
facebook.set_access_token(getToken)
#Gets info about myself
me = facebook.get_myself()
me_pic = facebook.fql_query('SELECT pic_small FROM user WHERE uid = me()')
#friends = facebook.get_friends()
me_name = me.name
me_id = me.id
me_gender = me.gender
location = getattr(me, "location")
me_location = location.name
for i in me_pic:
try:
my_pic = i.pic_small
except AttributeError:
my_pic = 'None'
try:
me_birthday = me.birthday
except AttributeError:
me_birthday = 'None'
try:
me_status = me.relationship_status
except AttributeError:
me_status = 'None'
try:
me_link = me.link
except AttributeError:
me_link = 'None'
me_all = {'name': me_name, 'id': me_id, 'gender': me_gender, 'location': me_location, 'birthday': me_birthday, 'status': me_status, 'link': me_link, 'picture': my_pic }
#db.dannysaban.insert(me_all)
#print 'me - done!'
#get_me = db.dannysaban.find({'id': me_id})
return me_all
''' update user data '''
示例2: Pyfb
# 需要導入模塊: from pyfb import Pyfb [as 別名]
# 或者: from pyfb.Pyfb import authenticate [as 別名]
#!/usr/bin/env python
from pyfb import Pyfb
#Your APP ID. It Needs to register your application on facebook
#http://developers.facebook.com/
FACEBOOK_APP_ID = '178358228892649'
facebook = Pyfb(FACEBOOK_APP_ID)
#Opens a new browser tab instance and authenticates with the facebook API
#It redirects to an url like http://www.facebook.com/connect/login_success.html#access_token=[access_token]&expires_in=0
facebook.authenticate()
#Copy the [access_token] and enter it below
token = raw_input("Enter the access_token\n")
#Sets the authentication token
facebook.set_access_token(token)
#Gets info about myself
me = facebook.get_myself()
print "-" * 40
print "Name: %s" % me.name
print "From: %s" % me.hometown.name
print
print "Speaks:"
for language in me.languages:
print "- %s" % language.name
示例3: Pyfb
# 需要導入模塊: from pyfb import Pyfb [as 別名]
# 或者: from pyfb.Pyfb import authenticate [as 別名]
__FILENAME__ = basics
#!/usr/bin/env python
from pyfb import Pyfb
#Your APP ID. It Needs to register your application on facebook
#http://developers.facebook.com/
FACEBOOK_APP_ID = '178358228892649'
facebook = Pyfb(FACEBOOK_APP_ID)
#Opens a new browser tab instance and authenticates with the facebook API
#It redirects to an url like http://www.facebook.com/connect/login_success.html#access_token=[access_token]&expires_in=0
facebook.authenticate()
#Copy the [access_token] and enter it below
token = raw_input("Enter the access_token\n")
#Sets the authentication token
facebook.set_access_token(token)
#Gets info about myself
me = facebook.get_myself()
print "-" * 40
print "Name: %s" % me.name
print "From: %s" % me.hometown.name
print
print "Speaks:"
for language in me.languages:
print "- %s" % language.name
示例4: Pyfb
# 需要導入模塊: from pyfb import Pyfb [as 別名]
# 或者: from pyfb.Pyfb import authenticate [as 別名]
from pyfb import Pyfb
#Your APP ID. You Need to register the application on facebook
#http://developers.facebook.com/
FACEBOOK_APP_ID = 'YOUR_APP_ID'
pyfb = Pyfb(FACEBOOK_APP_ID)
#Opens a new browser tab instance and authenticates with the facebook API
#It redirects to an url like http://www.facebook.com/connect/login_success.html#access_token=[access_token]&expires_in=0
pyfb.authenticate()
#Copy the [access_token] and enter it below
token = raw_input("Enter the access_token\n")
#Sets the authentication token
pyfb.set_access_token(token)
photos = pyfb.get_photos()
print "These are my photos:\n"
for photo in photos:
print photo.picture
#Just call the method next to get the next page of photos!
more_photos = photos.next()
print "\nMore photos:\n"
for photo in more_photos:
print photo.picture