我想确定一种方法,以便在Google电子表格工作簿中的每个工作表的URL中获取工作表ID.例如,对于"Sheet2的"工作表ID 此工作簿是"1244369280",因为它的网址是https://docs.google.com/spreadsheets/d/1yd8qTYjRns4_OT8PbsZzH0zajvzguKS79dq6j--hnTs/edit#gid=1244369280
我发现的一种方法是提取Google电子表格的XML,因为根据这个问题,获取工作表ID的唯一方法是流式传输工作表的XML,但示例是在Javascript中,我需要在Python中执行此操作
这是我想在Python中执行的Javascript代码:
Dim worksheetFeed As WorksheetFeed
Dim query As WorksheetQuery
Dim worksheet As WorksheetEntry
Dim output As New MemoryStream
Dim xml As String
Dim gid As String = String.Empty
Try
_service = New Spreadsheets.SpreadsheetsService("ServiceName")
_service.setUserCredentials(UserId, Password)
query = New WorksheetQuery(feedUrl)
worksheetFeed = _service.Query(query)
worksheet = worksheetFeed.Entries(0)
' Save worksheet feed to memory stream so we can
' get the xml returned from the feed url and look for
' the gid. Gid allows us …Run Code Online (Sandbox Code Playgroud) 使用jQuery:
$.getJSON('http://gdata.youtube.com/feeds/api/videos/b2-5GSjZvW8?v=2&alt=jsonc', function(meta){alert(meta.data.title);});
Run Code Online (Sandbox Code Playgroud)
Firefox和Chrome都按预期工作,但IE不断触发错误功能(使用时$.ajax)而不是成功.错误状态为"0",这没有多大帮助.
我已经使用也试图$.ajax与cache:false无济于事.
有任何想法吗?
我正在使用Python并尝试从公共Google电子表格(这一个)中检索数据,但在开发人员文档方面有点挣扎.
如果可能的话,我想避免客户端身份验证,因为它是一个公共电子表格.
这是我当前的代码,使用gdata库:
client = gdata.spreadsheet.service.SpreadsheetsService()
key = '0Atncguwd4yTedEx3Nzd2aUZyNmVmZGRHY3Nmb3I2ZXc'
worksheets_feed = client.GetWorksheetsFeed(key)
Run Code Online (Sandbox Code Playgroud)
这与BadStatusLine的第3行失败.
如何从电子表格中读取数据?
我正在尝试构建Zend_Gdata_Spreadsheets_ListQuery,但我找不到任何可以解释预期查询语法是什么的引用以及您可以执行和不执行的查询类型.我能找到的最接近的是[Google Data API Client Library(1.41.1)](https://developers.google.com/gdata/javadoc/com/google/gdata/client/spreadsheet/ ListQuery#ListQuery(java.net.URL)),它描述了函数setSpreadsheetQuery,如下所示:
setSpreadsheetQuery
public void setSpreadsheetQuery(java.lang.String query)设置结构化电子表格查询.参数:query - 查询,例如"name ='Sonja'和state ='Georgia'"
如果您正在寻找列标题为"name"且包含文本"Sonja"的单元格,则此方法可以正常工作.我正在寻找包含"Sonja"作为细胞文本一部分的细胞.例如,"name"列中值为"Sonja the Awesome"的单元格与上面的搜索不匹配.name = Sonya*导致错误,name ="Sonya*"不返回任何结果.
那么,有没有人知道我在哪里可以找到"结构化电子表格查询"的预期"结构"的概述?
我一直试图弄清楚这一段时间,但似乎没有能够突破,所以希望有人在那之前做过这件事.
我的问题是我正在尝试使用gdata python客户端库批量更新google电子表格并通过oauth2进行身份验证.我在这里找到了一个如何使用gdata.spreadsheet.service模块进行批量更新的示例:https://code.google.com/p/gdata-python-client/wiki/UsingBatchOperations
但是,当通过oauth2进行身份验证时,这似乎不起作用,因此我不得不使用gdata.spreadsheets.client模块,而不是如本文所述:https://code.google.com/p/gdata-python-client/问题/细节?ID = 549
使用gdata.spreadsheets.client模块可用于身份验证和更新工作表,但批处理命令似乎不起作用.下面是我最近的代码变体,它是我最接近的.它似乎工作但工作表没有更新,返回的batch_status是:'批量不支持插入'.(注意:我确实尝试在注释掉的代码中修改CellEntries的batch_operation和batch_id参数,但这也不起作用.)
感谢您的任何帮助,您可以提供.
import gdata
import gdata.gauth
import gdata.service
import gdata.spreadsheets
import gdata.spreadsheets.client
import gdata.spreadsheets.data
token = gdata.gauth.OAuth2Token(client_id=Client_id,client_secret=Client_secret,scope=Scope,
access_token=ACCESS_TOKEN, refresh_token=REFRESH_TOKEN,
user_agent=User_agent)
client = gdata.spreadsheets.client.SpreadsheetsClient()
token.authorize(client)
range = "D6:D13"
cellq = gdata.spreadsheets.client.CellQuery(range=range, return_empty='true')
cells = client.GetCells(file_id, 'od6', q=cellq)
objData = gdata.spreadsheets.data
batch = objData.BuildBatchCellsUpdate(file_id, 'od6')
n = 1
for cell in cells.entry:
cell.cell.input_value = str(n)
batch.add_batch_entry(cell, cell.id.text, batch_id_string=cell.title.text, operation_string='update')
n = n + 1
client.batch(batch, force=True)
Run Code Online (Sandbox Code Playgroud) 带有oauth2的管理员设置API
我正在尝试使用OAuth2凭据将使用python编写的应用程序连接到Admin Settings API,但是我收到错误消息:
源代码:
from oauth2client.client import Credentials
import gdata.apps.adminsettings.service
import gdata.gauth
#credentials_json is a string with an oauth2 credential that is saved in datastore
#domain_name is the name of the target domain
#app_name is my application name
credentials = Credentials.new_from_json(credentials_json)
auth2token = gdata.gauth.OAuth2TokenFromCredentials(credentials)
service = gdata.apps.adminsettings.service.AdminSettingsService(source=app_name,domain=domain_name)
service = auth2token.authorize(service)
print service.GetMaximumNumberOfUsers()
Run Code Online (Sandbox Code Playgroud)
例外:
Traceback (most recent call last):
File "<input>", line 25, in <module>
File "xxxxxxx\lib\gdata\apps\adminsettings\service.py", line 116, in GetMaximumNumberOfUsers
result = self.genericGet('general/maximumNumberOfUsers')
File "xxxxxxx\lib\gdata\apps\adminsettings\service.py", line 50, in genericGet …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用OAuth从python应用程序中获取Gmail原子提要.我有一个可以下载Google阅读器Feed的工作应用程序,我认为应该只是更改范围和Feed网址.替换URL后,我仍然可以成功获取请求和访问令牌,但是当我尝试使用访问令牌获取源时,我收到"401 Unauthorized"错误.这是我的简单测试程序:
import urlparse
import oauth2 as oauth
scope = "https://mail.google.com/mail/feed/atom/"
sub_url = scope + "unread"
request_token_url = "https://www.google.com/accounts/OAuthGetRequestToken?scope=%s&xoauth_displayname=%s" % (scope, "Test Application")
authorize_url = 'https://www.google.com/accounts/OAuthAuthorizeToken'
access_token_url = 'https://www.google.com/accounts/OAuthGetAccessToken'
oauth_key = "anonymous"
oauth_secret = "anonymous"
consumer = oauth.Consumer(oauth_key, oauth_secret)
client = oauth.Client(consumer)
# Get a request token.
resp, content = client.request(request_token_url, "GET")
request_token = dict(urlparse.parse_qsl(content))
print "Request Token:"
print " - oauth_token = %s" % request_token['oauth_token']
print " - oauth_token_secret = %s" % request_token['oauth_token_secret']
print
# …Run Code Online (Sandbox Code Playgroud) 我已经能够使用client.programmaticlogingdata下载包中的示例/电子表格,使用gdata python 函数登录Google电子表格.
现在我无法登录我的企业gapps'me@mycompany.com'我是否必须通过任何其他武器?我试过帐户类型托管没有工作.
我尝试oath2从gui 创建密钥,我生成了客户端ID和电子邮件ID.在gdata中运行oauth示例会询问consumerkey和secret密钥.有人可以就此提出建议吗?
我正在尝试使用Google的Objective-C Youtube API来获取youtube频道的播放列表 - 没有运气.
- 我从以下网址下载了Google的官方API:http: //code.google.com/p/gdata-objectivec-client/source/browse/#svn%2Ftrunk%2FExamples%2FYouTubeSample
但示例应用程序并没有真正做任何事情 - 它甚至不是iOS示例应用程序.似乎是一个Mac OS应用程序.它的Read-Me文件说:"这个示例应该自动构建并复制GTL.framework,作为构建和运行过程的一部分."
好的......然后是什么?
你如何在iPhone应用程序中使用它?
我没有找到任何实际的指示来完成这项工作.
知道我们应该在这做什么吗?