当前位置: 首页>>代码示例>>Python>>正文


Python Facebook.me方法代码示例

本文整理汇总了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
开发者ID:amalgamatedclyde,项目名称:Simple-Facebook-Login-on-Kivy,代码行数:78,代码来源:main.py

示例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()))
#.........这里部分代码省略.........
开发者ID:samjhyip,项目名称:Orbital2015---NUS-Next-Bus-2,代码行数:103,代码来源:main.py


注:本文中的facebook.Facebook.me方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。