I'm attempting to load the contents of a single cell of Google Sheet into a PHP variable. From there I intend to make an image change on a website when the cell contents are changed to different values. I can't get the cell contents to load into a PHP variable to get this ball rolling though.
Google Sheets API gives the following PHP code to do this:
$result = $service->spreadsheets_values->get($spreadsheetId, $range);
When I use this code after substituting my spreadsheetId and range, I echo $result and get nothing. I'm sure thre's something I'm missing in the code or that the variables $result or $service need to be defined, but Google dropped the ball on the PHP side aparently. Any help would be appreciated.
download the V1 master (not master) from: https://github.com/google/google-api-php-client-services/issues?utf8=%E2%9C%93&q=spreadsheets_values
copy on server, verify path of requires
put your code in an exemple, with the class declared for $service and variables $range, $spreadsheetId and $api_key (from explorer api of google, to auhenticate: https://console.developers.google.com/apis/credentials )
run the modified exemple
PS: I look for multi-range in case you find the method with :
$range[]= 'Sheet1!A:C'; // I try to have all sheets in once
$response = $service->spreadsheets_values->get($spreadsheetId, $range);
$values = $response->getValues();