/**
  * Insert a new row into this feed
  * 
  * @param array $row
  * 
  * @return void
  */
 public function insert($row)
 {
     $entry = new \SimpleXMLElement("\n            <entry\n                xmlns=\"http://www.w3.org/2005/Atom\"\n                xmlns:gsx=\"http://schemas.google.com/spreadsheets/2006/extended\">\n            </entry>\n        ");
     foreach ($row as $colName => $value) {
         $entry->addChild("xmlns:gsx:{$colName}", $value);
     }
     ServiceRequestFactory::getInstance()->post($this->getPostUrl(), $entry->asXML());
 }
 /**
  * Insert a new row into this feed
  * 
  * @param array $row
  * 
  * @return void
  */
 public function insert($row)
 {
     $entry = '<entry xmlns="http://www.w3.org/2005/Atom" xmlns:gsx="http://schemas.google.com/spreadsheets/2006/extended">';
     foreach ($row as $col => $val) {
         $entry .= '<gsx:' . $col . '>' . $val . '</gsx:' . $col . '>';
     }
     $entry .= '</entry>';
     $serviceRequest = ServiceRequestFactory::getInstance();
     $serviceRequest->getRequest()->setPost($entry);
     $serviceRequest->getRequest()->setMethod(Request::POST);
     $serviceRequest->getRequest()->setHeaders(array('Content-Type' => 'application/atom+xml'));
     $serviceRequest->getRequest()->setFullUrl($this->getPostUrl());
     $serviceRequest->execute();
 }
 /**
  * copy a spreadsheet
  * 
  * @param  string $id id of spreadsheet to copy, string $title name of copy
  * 
  * @return void
  */
 public function copySpreadsheet($id, $title)
 {
     $serviceRequest = ServiceRequestFactory::getInstance();
     $entry = '
         <entry xmlns="http://www.w3.org/2005/Atom">
           <id>https://docs.google.com/feeds/default/private/full/document:' . $id . '</id>
           <title>' . $title . '</title>
         </entry>
     ';
     $serviceRequest->getRequest()->setFullUrl('https://docs.google.com/feeds/documents/private/full');
     $serviceRequest->getRequest()->setMethod(Request::POST);
     $serviceRequest->getRequest()->setHeaders(array('Content-Type' => 'application/atom+xml'));
     $serviceRequest->getRequest()->setPost($entry);
     $res = $serviceRequest->execute();
     #        var_dump($res);
 }
 /**
  * Update the cell value
  * 
  * @return void
  */
 public function update()
 {
     $loc = $this->getCell();
     $serviceRequest = ServiceRequestFactory::getInstance();
     $entry = '
         <entry xmlns="http://www.w3.org/2005/Atom"
             xmlns:gs="http://schemas.google.com/spreadsheets/2006">
           <gs:cell row="' . $loc['row'] . '" col="' . $loc['col'] . '" inputValue="' . $this->cellValue . '"/>
         </entry>
     ';
     $serviceRequest->getRequest()->setFullUrl($this->postUrl);
     $serviceRequest->getRequest()->setMethod(Request::POST);
     $serviceRequest->getRequest()->setHeaders(array('Content-Type' => 'application/atom+xml'));
     $serviceRequest->getRequest()->setPost($entry);
     $ret = $serviceRequest->execute();
     $this->xml = new \SimpleXMLElement($ret);
 }
<?php

$path = $_SERVER['DOCUMENT_ROOT'] . '//';
require "vendor/autoload.php";
require $path . "GoogleAuthenticationHandler.php";
use Google\Spreadsheet\DefaultServiceRequest;
use Google\Spreadsheet\ServicerequestFactory;
use Google\Spreadsheet\SpreadsheetService;
$infoFile = fopen($path . "spreadsheetInfo.json", "r");
$info = json_decode(fread($infoFile, filesize($path . "spreadsheetInfo.json")), true);
$client = generateClient(true);
$serviceRequest = new DefaultServiceRequest(json_decode($client->getAccessToken(), true)["access_token"]);
ServiceRequestFactory::setInstance($serviceRequest);
$spreadsheetService = new SpreadsheetService();
$spreadsheetFeed = $spreadsheetService->getSpreadsheets();
$sheet = $spreadsheetFeed->getByTitle($info['spreadsheetName']);
$worksheetFeed = $sheet->getWorksheets();
$worksheet = $worksheetFeed->getByTitle($info['worksheetName']);
$listFeed = $worksheet->getListFeed();
$listFeed->insert($_POST);
header('Location: testIndex.php');
 /**
  * Returns a cell feed of the specified worksheet.
  * 
  * @see \Google\Spreadsheet\Worksheet::getWorksheetId()
  * 
  * @param string $worksheetId
  * 
  * @return \Google\Spreadsheet\CellFeed
  */
 public function getCellFeed($worksheetId)
 {
     return new CellFeed(ServiceRequestFactory::getInstance()->get("feeds/cells/{$worksheetId}/od6/private/full"));
 }
 public function getPostUrl()
 {
     $serviceRequest = ServiceRequestFactory::getInstance();
     $serviceRequest->getRequest()->setFullUrl($this->getCellFeedUrl());
     $res = $serviceRequest->execute();
     $xml = new \SimpleXMLElement($res);
     $postUrl = Util::getLinkHref($xml, 'http://schemas.google.com/g/2005#post');
     return $postUrl;
 }
 /**
  * Add a new worksheet to this spreadsheet
  * 
  * @param string $title
  *
  * @return \Google\Spreadsheet\Worksheet
  */
 public function addWorksheet($title, $rowCount = 100, $colCount = 10)
 {
     $entry = '
         <entry xmlns="http://www.w3.org/2005/Atom"
         xmlns:gs="http://schemas.google.com/spreadsheets/2006">
         <title>' . $title . '</title>
         <gs:rowCount>' . $rowCount . '</gs:rowCount>
         <gs:colCount>' . $colCount . '</gs:colCount>
         </entry>
     ';
     $serviceRequest = ServiceRequestFactory::getInstance();
     $serviceRequest->getRequest()->setFullUrl($this->getFeedUrl());
     $serviceRequest->getRequest()->setMethod(Request::POST);
     $serviceRequest->getRequest()->setPost($entry);
     $serviceRequest->getRequest()->setHeaders(array('Content-Type' => 'application/atom+xml'));
     $res = $serviceRequest->execute();
     return new Worksheet($res);
 }