本文整理汇总了Python中facebook.Facebook.me方法的典型用法代码示例。如果您正苦于以下问题:Python Facebook.me方法的具体用法?Python Facebook.me怎么用?Python Facebook.me使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类facebook.Facebook
的用法示例。
在下文中一共展示了Facebook.me方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: FacebookApp
# 需要导入模块: from facebook import Facebook [as 别名]
# 或者: from facebook.Facebook import me [as 别名]
class FacebookApp(App):
post_status = StringProperty('-')
user_infos = StringProperty('-')
facebook = ObjectProperty()
def build(self):
global app
app = self
return FacebookUI()
def on_start(self):
self.facebook = Facebook(FACEBOOK_APP_ID,
permissions=['publish_actions', 'basic_info'])
global modal_ctl
modal_ctl = ModalCtl()
netcheck.set_prompt(modal_ctl.ask_connect)
self.facebook.set_retry_prompt(modal_ctl.ask_retry_facebook)
def fb_me(self):
def callback(success, user=None, response=None, *args):
if not success:
return
'''since we're using the JNIus proxy's API here,
we have to test if we're on Android to avoid implementing
a mock user class with the verbose Java user interface'''
if platform() == 'android' and response.getError():
Logger.info(response.getError().getErrorMessage())
if platform() == 'android' and not response.getError():
infos = []
infos.append('Name: {}'.format(user.getName()))
infos.append('FirstName: {}'.format(user.getFirstName()))
infos.append('MiddleName: {}'.format(user.getMiddleName()))
infos.append('LastName: {}'.format(user.getLastName()))
infos.append('Link: {}'.format(user.getLink()))
infos.append('Username: {}'.format(user.getUsername()))
infos.append('Birthday: {}'.format(user.getBirthday()))
location = user.getLocation()
if location:
infos.append('Country: {}'.format(location.getCountry()))
infos.append('City: {}'.format(location.getCity()))
infos.append('State: {}'.format(location.getState()))
infos.append('Zip: {}'.format(location.getZip()))
infos.append('Latitude: {}'.format(location.getLatitude()))
infos.append('Longitude: {}'.format(location.getLongitude()))
else:
infos.append('No location available')
else:
infos = ['ha', 'ha', 'wish', 'this', 'was', 'real']
self.user_infos = '\n'.join(infos)
self.facebook.me(callback)
def fb_post(self, text):
def callback(success, response=None, *args):
if platform() == 'android' and response.getError():
Logger.info(response.getError().getErrorMessage())
Logger.info(str(success))
for a in args:
Logger.info(str(a))
if success:
from time import time
self.post_status = 'message posted at {}'.format(time())
self.facebook.post(text, callback=callback)
def fb_image_post(self, description, image_path):
def callback(success, *args):
Logger.info(str(success))
for a in args:
Logger.info(str(a))
if success:
from time import time
self.post_status = 'message posted at {}'.format(time())
self.facebook.image_post(description, image_path, callback=callback)
def on_pause(self):
return True
示例2: NUSNextBus
# 需要导入模块: from facebook import Facebook [as 别名]
# 或者: from facebook.Facebook import me [as 别名]
class NUSNextBus(App):
#Callback properties
post_status = StringProperty('-')
user_infos = StringProperty('-')
facebook = ObjectProperty()
#Class variables
_facebookid = StringProperty('')
_username = ''
_firstname = ''
_lastname = ''
all_saved_busstopNo = []
all_saved_busno = []
isRecordRetrieved = False
fb_userprofile = ObjectProperty()
def build(self):
global app
app = self
#Creating presentation retains an instance that we can reference to
root_widget = Builder.load_file("layout.kv")
#Saves a Reference of the Screen Manager
self.root_widget = root_widget
return root_widget
def on_start(self):
'''
Load Modules required for Facebook Login
'''
self.facebook = Facebook(FACEBOOK_APP_ID,permissions=['publish_actions', 'basic_info'])
#Sets up the AskUser() and PopUp() to ask for connection
global modal_ctlon_start
modal_ctl = ModalCtl()
#Define callback as modal_ctl.ask_connect()
netcheck.set_prompt(modal_ctl.ask_connect)
self.facebook.set_retry_prompt(modal_ctl.ask_retry_facebook)
'''
Load Bus Stop Directory
'''
#Retrieve Bus Stop Details from CSV
self.datamall_bus_stop = datamall_bus_stop.BusStop()
'''
Load Facebook Profile
'''
#Check if this is the first login
self.fb_userprofile = userprofile.UserProfile(self.user_data_dir)
#If existing user, IS_EXISTINGUSER=True
self.IS_EXISTINGUSER = self.fb_userprofile.isExistingUser
#If existing user, USER_PROFILE will not be an empty dict
self.USER_PROFILE = self.fb_userprofile._user_profile
if platform == 'android':
if self.IS_EXISTINGUSER:
#Loads Screen for existing Users
self.root_widget.current = 'searchscreen'
self._facebookid = self.USER_PROFILE['facebook_id']
self._firstname = self.USER_PROFILE['firstname']
self._lastname = self.USER_PROFILE['lastname']
else:
#Loads Screen for new users
self.root_widget.current = 'accountsettings'
#Not on android
else:
self.root_widget.current = 'PCaccountsettings'
'''
Update Footer for Search Screen(the main screen)
'''
self.root_widget.ids['searchbusscreen'].ids['footer'].ids['footer_search_button'].ids['footer_search_button_image'].source = 'data/Searches Folder_inactive.png'
#Allows for this app to be paused when Facebook app is opened
def on_pause(self):
Logger.info('Android: App paused, now wait for resume.')
return True
#Allows for this app to be resumed after Facebook authorisation is completed
def on_resume(self):
pass
def fb_me(self):
def callback(success, user=None, response=None, *args):
if not success:
return
'''since we're using the JNIus proxy's API here,
we have to test if we're on Android to avoid implementing
a mock user class with the verbose Java user interface'''
if platform() == 'android' and response.getError():
Logger.info(response.getError().getErrorMessage())
#If this platform is android & response type not error
if platform() == 'android' and not response.getError():
infos = []
infos.append('Name: {}'.format(user.getName()))
#.........这里部分代码省略.........