标签: google-spreadsheet-api

检查表是否存在于电子表格 Google 电子表格 API PHP 中

如何检查工作表是否存在于电子表格中(按名称检查工作表)或不使用 Google Sheet API。我用过Google Sheet API v4

如果工作表不存在,则创建一个新工作表。

谢谢

php google-api google-spreadsheet-api

6
推荐指数
1
解决办法
5381
查看次数

无需 Oauth 令牌即可访问 Google 电子表格 API

我已经阅读了谷歌电子表格文档https://developers.google.com/sheets/api/guides/authorizing并且它说,如果文档是公开的,你不需要 Oauth 2.0 并且 API 密钥就足够了。我正在尝试使用 hurl 和 api 密钥作为 parameter.it 进行测试请求,但它仍然给我错误,我需要使用 Oauth,有什么想法吗?

发布https://sheets.googleapis.com/v4/spreadsheets/16woR-nfy6KYBbkQpC2YOT1GzIean8rTzjueUnlzLMiE/values/Sheet1!A1:E1:append?valueInputOption=USER_ENTERED

回复: "error": {"code": 401,"message": "Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.","status": "UNAUTHENTICATED"}

google-authentication google-sheets google-spreadsheet-api google-developers-console

6
推荐指数
2
解决办法
4633
查看次数

在没有客户端登录的情况下使用 google sheet api

我有一个从 Google 电子表格中获取数据的网站。我希望我的用户无需登录即可查看获取的数据。这可能吗?如何实现?

为了获取和更新工作表数据,我只需要一个帐户,最好在服务器端登录。但是,我还没有看到任何不需要客户端登录的服务器端日志记录。

google-sheets google-spreadsheet-api

6
推荐指数
1
解决办法
7260
查看次数

如何使用支持的API从javascript读取/写入Google电子表格?

关于如何使用支持的API将javascript客户端(非小工具)写入私有Google电子表格,我感到非常困惑?我没有遇到OAuth2 Drive API客户端的问题,但是没有电子表格支持!

https://developers.google.com/apis-explorer

此问题粗略地要求电子表格API显示在该页面上:

http://code.google.com/p/google-api-javascript-client/issues/detail?id=37

我可能遗漏了一些明显的东西,所以谢谢你的善意帮助我......

更新:

哇,这是踢我的背后!因此,我将尝试从Oauth2工作流中获取access_token,然后设置gdata API Authorization标头,如下所示:

service = new google.gdata.client.GoogleService('testapp');
service.setHeaders({'Authorization': 'Bearer '+ access_token});
Run Code Online (Sandbox Code Playgroud)

不幸的是,chrome控制台显示当我执行类似操作时,此标头实际上并未发送到Google

service.getFeed(url, cb, eb);
Run Code Online (Sandbox Code Playgroud)

Uffff!

javascript gdata-api google-spreadsheet-api

5
推荐指数
1
解决办法
2525
查看次数

'str'不支持oauth的缓冲区接口Python 3错误

import json
import gspread
from oauth2client.client import SignedJwtAssertionCredentials

json_key = json.load(open('Crowds-9569176f5988.json'))
scope = ['https://spreadsheets.google.com/feeds']

credentials = SignedJwtAssertionCredentials(json_key['client_email'], json_key['private_key'], scope)
#gc = gspread.authorize(credentials)
Run Code Online (Sandbox Code Playgroud)

错误:

Traceback (most recent call last):   File "C:\Users\sony\Desktop\Python\new.py", line 8, in <module>
    credentials = SignedJwtAssertionCredentials(json_key['client_email'], json_key['private_key'], scope)   File "C:\Python34\lib\site-packages\oauth2client\util.py", line 137, in positional_wrapper
    return wrapped(*args, **kwargs)   File "C:\Python34\lib\site-packages\oauth2client\client.py", line 1469, in
__init__
    self.private_key = base64.b64encode(private_key)   File "C:\Python34\lib\base64.py", line 62, in b64encode
    encoded = binascii.b2a_base64(s)[:-1] TypeError: 'str' does not support the buffer interface
Run Code Online (Sandbox Code Playgroud)

我尝试使用编码字符串,.encode()gspread.authorize()不支持这种类型.这是[文档] [1],显然没什么帮助.我使用的是Python …

python google-spreadsheet-api gspread

5
推荐指数
1
解决办法
1502
查看次数

Google Apps脚本/表格返回错误请求400

我在Google表格上运行了一个非常简单的脚本。

该脚本接受Webhook POST,并将Webhook的内容写为电子表格中的新行。

该脚本可以正常运行,并且在接收数据时会写一个新行。

但是,出于某些原因,我从中发送Webhook的应用程序收到“ Bad Request 400”错误消息。即使该脚本可以工作,并且可以完成应有的工作。

这是我正在使用的脚本的小提琴

如果我手动调用此方法,则会收到200响应:

var response = UrlFetchApp.fetch("https://script.google.com/macros/s/AKfycbx5ubu78yi5sj2D9z-2m3Wqog604wY1ENwP3pZstnB95Mc5_N3b/exec", options);
Run Code Online (Sandbox Code Playgroud)

这是一个带有表单的登录页面。提交表单时,表单数据通过Webhook推送到Google表格。(单击“单击我以测试此脚本”以查看该表单,如果提交该表单,则将看到实际的工作表。)

google-sheets google-apps-script google-spreadsheet-api

5
推荐指数
1
解决办法
1369
查看次数

如何更新/写入数据到谷歌电子表格api android(api v4)

我一直致力于一个应用程序,我需要使用谷歌电子表格api编写和更新数据到电子表格.我已经关注了谷歌Google表格API Android快速入门提供的Android快速入门,并且能够从谷歌电子表格中检索数据,但我无法理解如何写入数据.请帮忙

android google-spreadsheet-api

5
推荐指数
2
解决办法
8222
查看次数

使用 API 密钥 (C#) 将数据写入 Google 电子表格

我有一个应用程序允许我使用 API 密钥从 Google 电子表格中读取数据。我只是让 HTTP GET 到这个地址并得到一个带有数据的响应。

https://sheets.googleapis.com/v4/spreadsheets/18soCZy9H4ZGuu**********BeHlNY1lD8at-Pbjmf8c/values/Sheet1!A1?key=AIzaSyAYJ***********pB-4iKZjYf4y0vhXP8OM
Run Code Online (Sandbox Code Playgroud)

但是当我尝试使用 HTTP PUT 写数据来寻址时

https://sheets.googleapis.com/v4/spreadsheets/18soCZy9H4ZGuu**********BeHlNY1lD8at-Pbjmf8c/values/Sheet1!A4?valueInputOption=RAW?key=AIzaSyAYJ***********pB-4iKZjYf4y0vhXP8OM
Run Code Online (Sandbox Code Playgroud)

它给了我 401 错误。发出 PUT 请求的代码:

 using (WebClient wc = new WebClient())
 {
     byte[] res = wc.UploadData(link, "PUT", Encoding.ASCII.GetBytes(textBox1.Text));
     MessageBox.Show(Encoding.Default.GetString(res));
 }
Run Code Online (Sandbox Code Playgroud)

此外,电子表格是完全公开的,任何人都可以在未经授权的情况下读写。我的猜测是我不能使用 API Key 将数据写入电子表格,唯一的方法是使用 OAuth。

更新: 所以我刚刚尝试使用 Google.Apis.Sheets.v4 来写入值,现在我几乎 100% 确定 API 密钥不能用于将数据写入 Google 电子表格。好吧,那我就用 OAuth 2.0。

c# google-spreadsheet-api

5
推荐指数
1
解决办法
4766
查看次数

通过 API 向 Google 电子表格添加多行

我可以使用以下代码向 Google 电子表格添加新行:

$valueRange = new Google_Service_Sheets_ValueRange();
$valueRange->setValues(["values" => ['data1', 'data2']]);
$range = 'Sheet1!A1:A';
$conf = ["valueInputOption" => "USER_ENTERED"];
$service->spreadsheets_values->append($spreadsheetId, $range, $valueRange, $conf);
Run Code Online (Sandbox Code Playgroud)

我应该如何更改 setValues 参数以添加多行?

谢谢你。

更新

同时我使用这种方法:

$range_number = 1; // Keep spreadsheet header
$data = array();
for($i=0;$i<count($data);$i++){
    $range_number++;
    $range = 'Sheet1!A'.$range_number.':XX';
    $values = array( array($data1[$i], $data2[$i], $data3[$i]) );
    $data[] = new Google_Service_Sheets_ValueRange(
        array( 'range' => $range, 'values' => $values )
    );
}
$body = new Google_Service_Sheets_BatchUpdateValuesRequest(array(
  'valueInputOption' => "USER_ENTERED",
  'data' => $data
));
$result = $service->spreadsheets_values->batchUpdate($spreadsheetId, $body); …
Run Code Online (Sandbox Code Playgroud)

php google-spreadsheet-api

5
推荐指数
1
解决办法
4704
查看次数

使用 php 按列以编程方式填充 Google 电子表格

问好!正如您通过查看我的个人资料可能已经猜到的那样,我对这个社区很陌生,所以我会尽我所能,尽可能详细和清楚地解释。:)

PS:如果您看到我可以做些什么来改进我的代码,请随时提出建议!(我有点初学者)

P.S2.:请记住,英语是我的第二语言,所以我可能会犯拼写/语法错误。

好的,这里是:

$client = new Google_Client();
    $client->setAuthConfig(__DIR__ . '/client_secret.json');
    $client->addScope(Google_Service_Drive::DRIVE);
    $client->setIncludeGrantedScopes(true);
    $service = new Google_Service_Sheets($client);
Run Code Online (Sandbox Code Playgroud)

上面的代码是我的初始化

while(($row = $mssql->fetch()) != false){
    $nbRows++;
    $data['MatchType'][] = $row['MatchType'];
    $data['AccountNo'][] = $row['AccountNo'];
    $data['AccountName'][] = $row['AccountName']; 
}
Run Code Online (Sandbox Code Playgroud)

所以基本上上面的代码块所做的是填充一个以列标题命名的数组,其中包含来自数据库一列的所有值。它将对数据库的所有列执行此操作。所以你最终会得到类似的东西:

data (
    MatchType (
        [0] => Success
        [1] => Failed
        [2] => Pending
        ...
    )
    AccountNo (
        [0] => 12345
        [1] => 23456
        [2] => 34567
        ...
    )
    AccountName (
        [0] => Family Dental
        [1] => Chez Germain et ses amis!
        [2] => 123 travellers's …
Run Code Online (Sandbox Code Playgroud)

php google-spreadsheet-api

5
推荐指数
0
解决办法
1061
查看次数