使用基于列表的Feed

时间:2016-06-02 08:08:32

标签: php curl google-sheets google-spreadsheet-api

我尝试使用基于基于列表的Feed,通过PHP curl使用简单的HTTP POST请求将多行添加到Google电子表格中。

以下是添加单行的代码,它运行正常,

    $postBody = '<entry xmlns="http://www.w3.org/2005/Atom" xmlns:gsx="http://schemas.google.com/spreadsheets/2006/extended">'
            . '<gsx:phonenumber>' . htmlspecialchars($parsed_data['phone']) . '</gsx:phonenumber>'
            . '<gsx:restaurantname>' . htmlspecialchars($parsed_data['restaurant_name']) . '</gsx:restaurantname>'
            . '<gsx:item>' . htmlspecialchars($item['item']) . '</gsx:item>'
            . '<gsx:qty>' . htmlspecialchars($item['qty']) . '</gsx:qty>'
            . '<gsx:price>' . htmlspecialchars($item ['price']) . '</gsx:price>'
            . '<gsx:specialinstructions>' . htmlspecialchars($item['special_instructions']) . '</gsx:specialinstructions>'
            . '<gsx:menuchoice>' . htmlspecialchars($item['menu_choice']) . '</gsx:menuchoice>'
            . '</entry>';

但我试图像这样一次添加多行,但它不会添加,而是添加一行。

    $postBody = '<entry xmlns="http://www.w3.org/2005/Atom" xmlns:gsx="http://schemas.google.com/spreadsheets/2006/extended">'
            . '<gsx:phonenumber>' . htmlspecialchars($parsed_data['phone']) . '</gsx:phonenumber>'
            . '<gsx:restaurantname>' . htmlspecialchars($parsed_data['restaurant_name']) . '</gsx:restaurantname>'
            . '<gsx:item>' . htmlspecialchars($item['item']) . '</gsx:item>'
            . '<gsx:qty>' . htmlspecialchars($item['qty']) . '</gsx:qty>'
            . '<gsx:price>' . htmlspecialchars($item ['price']) . '</gsx:price>'
            . '<gsx:specialinstructions>' . htmlspecialchars($item['special_instructions']) . '</gsx:specialinstructions>'
            . '<gsx:menuchoice>' . htmlspecialchars($item['menu_choice']) . '</gsx:menuchoice>'
            . '<gsx:phonenumber>' . htmlspecialchars($parsed_data['phone']) . '</gsx:phonenumber>'
            . '<gsx:restaurantname>' . htmlspecialchars($parsed_data['restaurant_name']) . '</gsx:restaurantname>'
            . '<gsx:item>' . htmlspecialchars($item['item']) . '</gsx:item>'
            . '<gsx:qty>' . htmlspecialchars($item['qty']) . '</gsx:qty>'
            . '<gsx:price>' . htmlspecialchars($item ['price']) . '</gsx:price>'
            . '<gsx:specialinstructions>' . htmlspecialchars($item['special_instructions']) . '</gsx:specialinstructions>'
            . '<gsx:menuchoice>' . htmlspecialchars($item['menu_choice']) . '</gsx:menuchoice>'
            . '</entry>';

有人知道如何仅使用一个POST请求添加多行?

0 个答案:

没有答案