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


Python Facebook.get_ext_perm_url方法代码示例

本文整理汇总了Python中facebook.Facebook.get_ext_perm_url方法的典型用法代码示例。如果您正苦于以下问题:Python Facebook.get_ext_perm_url方法的具体用法?Python Facebook.get_ext_perm_url怎么用?Python Facebook.get_ext_perm_url使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在facebook.Facebook的用法示例。


在下文中一共展示了Facebook.get_ext_perm_url方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: MainWindow

# 需要导入模块: from facebook import Facebook [as 别名]
# 或者: from facebook.Facebook import get_ext_perm_url [as 别名]
class MainWindow(QtGui.QDialog):
	def __init__(self, parent=None):
		super(MainWindow, self).__init__(parent)
		self.selectFileButton = QPushButton('Select File',self)
		self.connect(self.selectFileButton,SIGNAL("clicked()"), self._selectFile)
		self.loginButton = QPushButton('Login',self)
		self.connect(self.loginButton,SIGNAL("clicked()"), self._login)

		mainLayout = QtGui.QGridLayout()
		mainLayout.addWidget(self.selectFileButton,0,0)
		mainLayout.addWidget(self.loginButton,0,1)
		self.setLayout(mainLayout)

		self.stage = 0

		self.options = {0:self._loginStage1,
				1:self._loginStage2,
				2:self._loginStage3,
				3:self._loginEnd}

		cf = ConfigFile(config_file_path)

		# get api_key, secret_key and app_Id
		try:
			self.api_key = cf.api_key
			self.secret_key = cf.secret_key
			self.app_Id = cf.app_Id
		except:
			self.api_key = ''
			self.secret_key = ''
			self.app_Id = ''
		# get token and expire time
		try:
			self.token = cf.token
			self.expire = val(cf.expire)
		except:
			self.token = 0
			self.expire = 0

		self.facebook = Facebook(self.api_key, self.secret_key)
		self.facebook.auth.createToken()

	def _selectFile(self):
		self.excelFileName = QFileDialog.getOpenFileName(self,"FileDialog","", "*.xls", "*.xls")
		reader = ExcelFileReader()
		reader.load(self.excelFileName)
		print reader.getHeader()
		print len(reader)
		for r in reader:
			print r

	def _login(self):
		auth_url = self.facebook.get_login_url(next=None,popup=True,canvas=True)
		self.loginWindow = LoginWindow(self)
		self.loginWindow.view.loadFinished.connect(self._stateMachine)
		self.loginWindow.show()
		self.loginWindow.view.load(QUrl(auth_url))
		self.loginButton.hide()
	
	def _stateMachine(self):
		self.options[self.stage]()

	def _loginStage1(self):
		url = str(self.loginWindow.view.url().toString())
		parser = ParseFacebookUrl(url)
		if parser.url != 'https://ssl.facebook.com/desktopapp.php':
			return
		if parser.query.has_key('api_key')==True:
			if parser.query['api_key'] == self.api_key:
				if skip_auth == False:
					self.stage = 1

					extpermurl = self.facebook.get_ext_perm_url(ext_perm='publish_stream', next=None, popup=True)
					self.loginWindow.view.load(QUrl(extpermurl))
				else:
					self.stage = 2
					self._stateMachine()

	def _loginStage2(self):

		self.stage = 2


	def _loginStage3(self):
		self.stage = 3

		self.facebook.auth.getSession()
#		photos = self.facebook.photos.createAlbum('test album2','home','interesting test album')
#		print photos
#		self.facebook.photos.upload(image='C:\\Temp\\facebookupload\\uploadphoto\\logo.gif', aid=photos[u'aid'], caption='good')
				

	def _loginEnd(self):
		self.stage = 4
开发者ID:sisilet,项目名称:photoupload,代码行数:96,代码来源:main.py


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