2017-10-11 1 views
1

ich kann einen Zellenwert mit Google API aktualisieren?Zellenwert mit GoogleSheets aktualisieren Api

bereits kann ich alle Werte von einem Google-Blatt lesen, aber ich kann keinen Wert aktualisieren.

ich versuche dies:

$body = new Google_Service_Sheets_ValueRange(array(
      'values' => $locations 
     )); 
     $params = array(
      'valueInputOption' => $locations 
     ); 

     $result2 = $service->spreadsheets_values->update($spreadsheetId, "A1", $body, $params); 
     print($result2); 

aber ich bekomme diese Fehlermeldung:

Fatal error: Uncaught Google_Service_Exception: { 
"error": { 
    "code": 400, 
    "message": "Invalid value at 'data.values[0]' (type.googleapis.com/google.pr 
otobuf.ListValue), \"Stant 1\"\nInvalid value at 'data.values[1]' (type.googleap 
is.com/google.protobuf.ListValue), \"Stant 10\"\nInvalid value at 'value_input_o 
ption' (TYPE_ENUM), \"\"", 
    "errors": [ 
    { 
     "message": "Invalid value at 'data.values[0]' (type.googleapis.com/googl 
e.protobuf.ListValue), \"Stant 1\"\nInvalid value at 'data.values[1]' (type.goog 
leapis.com/google.protobuf.ListValue), \"Stant 10\"\nInvalid value at 'value_inp 
ut_option' (TYPE_ENUM), \"\"", 
     "domain": "global", 
     "reason": "badRequest" 
    } 
    ], 
    "status": "INVALID_ARGUMENT" 
} 
} 
+0

Können Sie '$ params' drucken? –

+0

Ich finde die Lösung, danke, und ja, $ Optionen war das Problem, sollte dies tun: $ params = array ('valueInputOption' => 'RAW'); –

Antwort

0

ok danke, ich finde die Lösung ->

$options = array('valueInputOption' => 'RAW'); 

http://ajaxray.com/blog/store-data-to-google-sheets-using-php/

$options = array('valueInputOption' => 'RAW'); 
    $values = [ 
     ["Name", "Roll No.", "Contact"], 
     ["Anis", "001", "+88017300112233"], 
     ["Ashik", "002", "+88017300445566"] 
    ]; 
    $body = new Google_Service_Sheets_ValueRange(['values' => $values]); 

    $result = $service->spreadsheets_values->update(SHEET_ID, 'A1:C3', $body, $options); 
    print($result->updatedRange. PHP_EOL); 
Verwandte Themen