PHP Google Drive API Create New Row In Spreadsheet

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • smartic
    New Member
    • May 2007
    • 150

    PHP Google Drive API Create New Row In Spreadsheet

    I need to insert new row into Spreadsheet, i just need help to solve this problem ?

    Code:
    $service = new Google_DriveService($client);
    // create empty Spreadsheet
    $array = insertFile($service,'Google Maps Mrakers','ADD Google Map Mrakers To File',NULL,'application/vnd.google-apps.spreadsheet',false);
    // Get the access_token string and save it
    $auth = json_decode($client->getAccessToken(), true);
    $access_token = $auth['access_token'];
    // send the sheet data
    $headers = array(
        'Authorization: OAuth '.$access_token,
        'GData-Version:3.0',
        'Content-Type:application/atom+xml'
    );
    // Spreadsheet url
    $url = 'https://spreadsheets.google.com/feeds/list/'.$array['id'].'/1/private/full';
    $curl = curl_init($url);
    curl_setopt($curl, CURLOPT_HTTPHEADER,$headers);
    curl_setopt($curl, CURLOPT_POST,true);
    //curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS,'<entry xmlns="http://www.w3.org/2005/Atom" xmlns:gsx="http://schemas.google.com/spreadsheets/2006/extended">
        <gsx:hours>1</gsx:hours>
        <gsx:ipm>1</gsx:ipm>
        <gsx:items>60</gsx:items>
        <gsx:name>Elizabeth Bennet</gsx:name>
    </entry>');
    $response = curl_exec($curl);
    curl_close($curl);
    return's We're sorry, a server error occurred. Please wait a bit and try reloading your spreadsheet.
Working...