php - 使用 php 在 google sheet 上附加数据适用于本地主机,但不适用于 Cpanel
问题描述
我能够让我的代码使用 Google API 将表单提交的数据附加到 google sheet 文档
<?php
require __DIR__ . '/vendor/autoload.php';
$client = new \Google_Client();
$client->setApplicationName('php to sheets');
$client->setScopes([\Google_Service_Sheets::SPREADSHEETS]);
$client->setAccessType('offline');
$client->setAuthConfig(__DIR__ . '/credentials.json');
$service = new Google_Service_Sheets($client);
$spreadsheetId = "1QB_xjhw18b7J7WG0BSYkjf9RgqqgZspz_KYmBqD9yS4";
if (!empty($_POST)){
echo $_POST['name'];
$range = "congress";
$values = [
[$_POST['name'] , $_POST['rating'] , $_POST['notes'] ],
];
$body = new Google_Service_Sheets_ValueRange([
'values' => $values
]);
$params = [
'valueInputOption' => 'RAW'
];
$insert = [
"insertDataOption" => "INSERT_ROWS"
];
$result = $service->spreadsheets_values->append(
$spreadsheetId,
$range,
$body,
$params,
$insert
);
header("Location: Thanks.html");
}
?>
一旦我上传了项目文件夹,页面就会卡在文件上并且不会更新谷歌表
解决方案
推荐阅读
- scala - 尝试使用 spark 读取位于 ap-east-1 区域的存储桶中的数据存储时出现错误 400
- javascript - 根据 heightValueStart 和 animalNumbersRank 进行排序
- jquery - jQuery 未加载到 WordPress 中的自定义 js 文件中
- javascript - 使用 Vue.js 时如何突出显示 Vuetify 卡片中的单词?
- reactjs - 如何使用 React useRef 避免 TypeScript 错误?
- raspbian - 未安装 Apache 配置文件
- sql - 使用 Pymssql 将数据插入 MS SQL DB 时出错
- java - 无法解决“清单合并失败:属性 application@appComponentFactory”
- r - r papaja::printnum(0L, numbers =F) 返回空值,而不是“零”
- javascript - 动态形式的价值转移错误信息