【发布时间】:2014-05-01 01:37:36
【问题描述】:
Google API 没有对 PHP 的内置支持(显然 Zend 框架集成不再受支持)。因此,我一直在使用 Curl 从电子表格中读取和写入。 Like This
我需要的大部分内容都可以在这里找到:https://developers.google.com/google-apps/spreadsheets/ 在“协议”标签下。
但是,我现在想删除一行,文档显示这样做:
删除 https://spreadsheets.google.com/feeds/list/key/worksheetId/private/full/rowId/rowVersion
问题是Curl不支持delete。我通常使用POST 或GET。如何通过 curl 发出这样的命令?还有其他方法可以通过 curl 删除列表行吗?
根据下面 jeroen 的回答,我尝试了以下方法:
$headers = array(
"Authorization: GoogleLogin auth=" . $auth,
"GData-Version: 3.0",
);
$curl = curl_init();
$curl_setopt($curl, CURLOPT_URL, "https://spreadsheets.google.com/feeds/list/key/0/private/full/1a8lrz");
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "DELETE");
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_VERBOSE, true);
$response = curl_exec($curl);
但我绝对没有得到任何回应,完全没有错误。我已完全启用错误报告,并且我用于身份验证的 $auth 变量适用于对此电子表格的其他调用
【问题讨论】:
标签: php curl google-api google-spreadsheet-api