Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/294.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 批量更新单元格不适用于google电子表格api_Php_Google Spreadsheet Api - Fatal编程技术网

Php 批量更新单元格不适用于google电子表格api

Php 批量更新单元格不适用于google电子表格api,php,google-spreadsheet-api,Php,Google Spreadsheet Api,我设法更新了单个单元格,现在我试图批量更新多个单元格,但它不起作用。请告诉我这个代码出了什么问题。 这是我正在使用的代码: $feed = "<feed xmlns='http://www.w3.org/2005/Atom' xmlns:batch='http://schemas.google.com/gdata/batch' xmlns:gs='http://schemas.google.com/spreadsheets/2006'>\n"; $feed .= "&

我设法更新了单个单元格,现在我试图批量更新多个单元格,但它不起作用。请告诉我这个代码出了什么问题。 这是我正在使用的代码:

$feed = "<feed xmlns='http://www.w3.org/2005/Atom' xmlns:batch='http://schemas.google.com/gdata/batch' xmlns:gs='http://schemas.google.com/spreadsheets/2006'>\n";
        $feed .= "<id>https://spreadsheets.google.com/feeds/cells/$gID/$workSheetID/private/full</id>\n";

        foreach($postData as $post)
        {
            $row = $post["row"];
            $col = $post["col"];
            $data = $post["data"];
            $rc = "R$row" . "C$col";
            $requestURL = "https://spreadsheets.google.com/feeds/cells/$gID/$workSheetID/private/full/batch";
            $url = "https://spreadsheets.google.com/feeds/cells/$gID/$workSheetID/private/full/$rc";

            $feed .= "<entry>\n";
            $feed .= "<batch:id>A$row</batch:id>\n";
            $feed .= "<batch:operation type = 'update'/>\n";
            $feed .= "<id>$url</id>\n";
            $feed .= "<link rel='edit' type='application/atom+xml' href=$url />\n";
            $feed .= "<gs:cell row=$row col=$col inputValue='newData' />\n";
            $feed .= "</entry>\n";
        }
        $feed .= "</feed>";

        $curl = curl_init();
        curl_setopt($curl, CURLOPT_URL, $requestURL);
        curl_setopt($curl, CURLOPT_POSTFIELDS, $feed);
        curl_setopt($curl, CURLOPT_HEADER, false);
        $headers = array(
            "Authorization: Bearer " . $this->accessTokenArray->access_token,
            "GData-Version: 3.0",
            "Content-Type: application/atom+xml",
            "If-Match: *",
        );
        curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
        curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($curl, CURLOPT_VERBOSE, true);
        $httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
        return curl_exec($curl);
$feed=“\n”;
$feed.=”https://spreadsheets.google.com/feeds/cells/$gID/$workSheetID/private/full\n”;
foreach($postData作为$post)
{
$row=$post[“行”];
$col=$post[“col”];
$data=$post[“数据”];
$rc=“R$row”“C$col”;
$requestURL=”https://spreadsheets.google.com/feeds/cells/$gID/$workSheetID/private/full/batch”;
$url=”https://spreadsheets.google.com/feeds/cells/$gID/$workSheetID/private/full/$rc”;
$feed.=“\n”;
$feed.=“A$row\n”;
$feed.=“\n”;
$feed.=“$url\n”;
$feed.=“\n”;
$feed.=“\n”;
$feed.=“\n”;
}
$feed.=”;
$curl=curl_init();
curl_setopt($curl,CURLOPT_URL,$requestURL);
curl_setopt($curl,CURLOPT_POSTFIELDS,$feed);
curl_setopt($curl,CURLOPT_头,false);
$headers=数组(
“授权:承载”..$this->accessTokenArray->access\u令牌,
“GData版本:3.0”,
“内容类型:应用程序/atom+xml”,
“如果匹配:”,
);
curl_setopt($curl,CURLOPT_HTTPHEADER,$headers);
curl_setopt($curl,CURLOPT_SSL_VERIFYPEER,false);
curl_setopt($curl,CURLOPT_RETURNTRANSFER,1);
curl_setopt($curl,CURLOPT_VERBOSE,true);
$httpCode=curl\u getinfo($curl,CURLINFO\u HTTP\u CODE);
返回curl\u exec($curl);
这是我得到的结果:

<?xml version='1.0' encoding='UTF-8'?>
<feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearch/1.1/' xmlns:batch='http://schemas.google.com/gdata/batch' xmlns:gs='http://schemas.google.com/spreadsheets/2006'>
<id>https://spreadsheets.google.com/feeds/cells/1/13IBClQO0ZUdDXrPhEkpesKE6FKCxWDtPqLQXoK_JWXg/batch/1437040636408</id>
<updated>2015-07-16T09:57:16.413Z</updated>
<title>Batch Feed</title>
<entry>
<id>https://spreadsheets.google.com/feeds/cells/1/13IBClQO0ZUdDXrPhEkpesKE6FKCxWDtPqLQXoK_JWXg/batch/1437040636408/fatal</id>
<updated>2015-07-16T09:57:16.413Z</updated>
<title>Fatal Error</title>
<content>Feed processing was interrupted.</content>
<batch:interrupted reason='[Line 3, Column 8, element feed] The spreadsheet at this URL could not be found. Make sure that you have the right URL and that the owner of the spreadsheet hasn&apos;t deleted it.' parsed='0' success='0' error='0' unprocessed='0'/>
</entry>
</feed>

https://spreadsheets.google.com/feeds/cells/1/13IBClQO0ZUdDXrPhEkpesKE6FKCxWDtPqLQXoK_JWXg/batch/1437040636408
2015-07-16T09:57:16.413Z
分批进料
https://spreadsheets.google.com/feeds/cells/1/13IBClQO0ZUdDXrPhEkpesKE6FKCxWDtPqLQXoK_JWXg/batch/1437040636408/fatal
2015-07-16T09:57:16.413Z
致命错误
饲料加工中断。

尝试在所有URL中交换键和工作表TID的值以进行批量更新调用,包括XML提要中的URL,并且成功。

尝试在所有URL中交换键和工作表TID的值以进行批量更新调用,包括XML提要中的URL,并且成功。

通过编辑以下代码行来更改版本

GData-Version: 1.0". 

$url = "https://spreadsheets.google.com/feeds/cells/$gID/$workSheetID/private/full/$rc";
应该包括$rc之后的版本,它必须是

https://spreadsheets.google.com/feeds/cells/key/worksheetId/private/full/R2C5/version, 
检查文档。

希望这会有所帮助。

通过编辑以下代码行来更改版本

GData-Version: 1.0". 

$url = "https://spreadsheets.google.com/feeds/cells/$gID/$workSheetID/private/full/$rc";
应该包括$rc之后的版本,它必须是

https://spreadsheets.google.com/feeds/cells/key/worksheetId/private/full/R2C5/version, 
检查文档。
希望这会有所帮助