asimlqt / php-google-spreadsheet-client

A PHP library for accessing and manipulating Google Spreadsheets
Other
543 stars 154 forks source link

A working example and Google Errors!!! #166

Open raygig opened 7 years ago

raygig commented 7 years ago

I have spent a few hours now trying to get the examples in this repo to work and keep runnning into issues.

My latest one is an error from Google We're sorry. This document is not published.

Not sure why this is happening because I am using a valid access token. Regardless, I then published the document and then was prompted with another error.

Sorry, unable to open the file at this time. Please check the address and try again.

Is anyone else pulling out there hair as I am?

Doc URL: https://docs.google.com/spreadsheets/d/1tftyNypXdc6bX3EIXH3kG49AV14irkHaxgm6K81jssQ/edit#gid=0

$serviceRequest = new DefaultServiceRequest($accessToken["access_token"]);
$serviceRequest->setSslVerifyPeer(false);
ServiceRequestFactory::setInstance($serviceRequest);

/*
$serviceRequest = new DefaultServiceRequest("");
$serviceRequest->setSslVerifyPeer(false);
ServiceRequestFactory::setInstance($serviceRequest);
*/

$spreadsheetService = new Google\Spreadsheet\SpreadsheetService();
$worksheetFeed = $spreadsheetService->getPublicSpreadsheet("1tftyNypXdc6bX3EIXH3kG49AV14irkHaxgm6K81jssQ");
$worksheet = $worksheetFeed->getByTitle('Sheet1');

$cellFeed = $worksheet->getCellFeed();

$batchRequest = new Google\Spreadsheet\Batch\BatchRequest();
$batchRequest->addEntry($cellFeed->createCell(2, 1, "111"));
$batchRequest->addEntry($cellFeed->createCell(3, 1, "222"));
$batchRequest->addEntry($cellFeed->createCell(4, 1, "333"));
$batchRequest->addEntry($cellFeed->createCell(5, 1, "=SUM(A2:A4)"));

$batchResponse = $cellFeed->insertBatch($batchRequest);
ray-kay commented 6 years ago

Facing the same issue @Luki93 please advise

elstiko commented 6 years ago

I got scared about deprecation of v3 the other day and just started rebuilding for v4 without this library, it's not as hard as it seems, but a v4 update of this would be amazing by comparison.

asimlqt commented 6 years ago

I did look into updating this library to v4 quite a while back when it was released but I realized that the google php sdk was so easy to use and I didn't know what I could add to make it any easier.

I only got as far as doing the authentication, which to be fair does require a bit of work and could be simplified but after that I didn't know what else I could do :)

@elstiko Since you've worked with v4 do you have any suggestions what could be improved?