We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
function insert_data_to_google_sheet($data): void { $client = getGoogleClient(); $service = new \Google_Service_Sheets($client); $spreadsheetId = '1BgVqitbiMSP2sNQNy1hk0PCoItxacbyeZvjH8Zc2qu0'; $range = 'Sheet1'; $values = [ $data ]; $valueRange = new \Google_Service_Sheets_ValueRange(); $valueRange->setValues($values); // I have tried the following statement as well // $body = new \Google_Service_Sheets_ValueRange([ // "values" => $values // ]); $params = [ 'valueInputOption' => 'RAW' ]; // appending record to sheet $result = $service->spreadsheets_values->append($spreadsheetId, $range, $valueRange, $params); echo '<pre>'; print_r($result); echo '</pre>'; // return $result; }
$result is showing the following output instead of inserting the data:
GuzzleHttp\Psr7\Request Object ( [method:GuzzleHttp\Psr7\Request:private] => POST [requestTarget:GuzzleHttp\Psr7\Request:private] => [uri:GuzzleHttp\Psr7\Request:private] => GuzzleHttp\Psr7\Uri Object ( [scheme:GuzzleHttp\Psr7\Uri:private] => https [userInfo:GuzzleHttp\Psr7\Uri:private] => [host:GuzzleHttp\Psr7\Uri:private] => sheets.googleapis.com [port:GuzzleHttp\Psr7\Uri:private] => [path:GuzzleHttp\Psr7\Uri:private] => /v4/spreadsheets/1BgVqitbiMSP2sNQNy1hk0PCoItxacbyeZvjH8Zc2qu0/values/Sheet1:append [query:GuzzleHttp\Psr7\Uri:private] => valueInputOption=RAW [fragment:GuzzleHttp\Psr7\Uri:private] => ) [headers:GuzzleHttp\Psr7\Request:private] => Array ( [host] => Array ( [0] => sheets.googleapis.com ) [content-type] => Array ( [0] => application/json ) [x-php-expected-class] => Array ( [0] => Google\Service\Sheets\AppendValuesResponse ) ) [headerLines:GuzzleHttp\Psr7\Request:private] => Array ( [Host] => Array ( [0] => sheets.googleapis.com ) [content-type] => Array ( [0] => application/json ) [X-Php-Expected-Class] => Array ( [0] => Google\Service\Sheets\AppendValuesResponse ) ) [protocol:GuzzleHttp\Psr7\Request:private] => 1.1 [stream:GuzzleHttp\Psr7\Request:private] => GuzzleHttp\Psr7\Stream Object ( [stream:GuzzleHttp\Psr7\Stream:private] => Resource id #148 [size:GuzzleHttp\Psr7\Stream:private] => [seekable:GuzzleHttp\Psr7\Stream:private] => 1 [readable:GuzzleHttp\Psr7\Stream:private] => 1 [writable:GuzzleHttp\Psr7\Stream:private] => 1 [uri:GuzzleHttp\Psr7\Stream:private] => php://temp [customMetadata:GuzzleHttp\Psr7\Stream:private] => Array ( ) ) )
I need urgent help, please connect with someone who has already faced an issue like this.
Thanks
The text was updated successfully, but these errors were encountered:
Hello @rajklakhani! Thanks for the message!
I recommend taking a look at this snippet: https://github.com/googleworkspace/php-samples/blob/main/sheets/snippets/src/SpreadsheetAppendValues.php
Also got a question, have you used the setUseBatch method on the client? code reference as that is the expected behaviour when batch mode is set.
setUseBatch
client
Sorry, something went wrong.
No branches or pull requests
$result is showing the following output instead of inserting the data:
I need urgent help, please connect with someone who has already faced an issue like this.
Thanks
The text was updated successfully, but these errors were encountered: