def createHeaderRow(self,url):
header = { 'User-Agent' : self.user_agent, 'Authorization' : 'GoogleLogin auth=%s' % self.authorization.getToken('wise'), 'GData-Version' : '3.0', "If-Match" : '*', 'Content-Type': 'application/atom+xml'}
entry = '<?xml version=\'1.0\' encoding=\'UTF-8\'?><entry xmlns="http://www.w3.org/2005/Atom" xmlns:gsx="http://schemas.google.com/spreadsheets/2006/extended"> <gsx:hours>1</gsx:hours></entry>'
req = urllib2.Request(url, entry, header)
try:
response = urllib2.urlopen(req)
except urllib2.URLError, e:
if e.code == 403 or e.code == 401:
self.service.refreshToken()
header = { 'User-Agent' : self.user_agent, 'Authorization' : 'GoogleLogin auth=%s' % self.authorization.getToken('wise'), 'GData-Version' : '3.0', "If-Match" : '*', 'Content-Type': 'application/atom+xml'}
req = urllib2.Request(url, entry, header)
try:
response = urllib2.urlopen(req)
except urllib2.URLError, e:
xbmc.log(self.addon.getAddonInfo('name') + ': ' + str(e), xbmc.LOGERROR)
return False
else:
xbmc.log(self.addon.getAddonInfo('name') + ': ' + str(e), xbmc.LOGERROR)
return False
response.read()
response.close()
return True
#
# returns a list of worksheets with a link to their listfeeds
#
gSheets_api4.py 文件源码
python
阅读 23
收藏 0
点赞 0
评论 0
评论列表
文章目录