unable to access google spreedsheets values using php -


i'm installed google api oauth2 php lib; here: https://code.google.com/p/google-api-php-client/ google spreadsheet api php lib; here: https://github.com/asimlqt/php-google-spreadsheet-client

created credentials on api console using service account https://console.developers.google.com/

here php script used in combination above:

require_once('vendor/autoload.php');  require_once('vendor/composer/autoload_classmap.php');  require_once('vendor/composer/autoload_real.php');  require_once __dir__.'/vendor/google/apiclient/src/google/auth/assertioncredentials.php';  use google\spreadsheet\defaultservicerequest; use google\spreadsheet\servicerequestfactory; use google\spreadsheet\spreadsheetservice;  const g_client_id       = 'my_client_id'; const g_client_email    = 'email address'; const g_client_key_path = 'key.p12'; const g_client_key_pw   = 'notasecret';   $obj_client_auth  = new google_client (); $obj_client_auth -> setapplicationname ('newproject'); $obj_client_auth -> setclientid (g_client_id); $obj_client_auth -> setassertioncredentials (new google_auth_assertioncredentials (     g_client_email,      array('https://spreadsheets.google.com/feeds','https://docs.google.com/feeds'),      file_get_contents (g_client_key_path),      g_client_key_pw )); $obj_client_auth -> getauth () -> refreshtokenwithassertion (); $obj_token  = json_decode ($obj_client_auth -> getaccesstoken ()); $accesstoken = $obj_token->access_token; $servicerequest = new defaultservicerequest($accesstoken); servicerequestfactory::setinstance($servicerequest); $spreadsheetservice = new google\spreadsheet\spreadsheetservice(); $spreadsheetfeed = $spreadsheetservice->getspreadsheets(); $spreadsheet = $spreadsheetfeed->getbytitle('newspreadsheet'); $worksheetfeed = $spreadsheet->getworksheets(); $worksheet = $worksheetfeed->getbytitle('sssnew worksheet'); $listfeed = $worksheet->getlistfeed(); $row = array('name'=>'john', 'age'=>25); 

i receive following error: call member function getworksheets() on non-object... i'm not getting how correct it... n suggestions

i got it... issue didn't share spreadsheet... when shared spreadsheet client email i'm able insert records desired sheets... i'm able access every sheet,insert,delete everything...

so, when ever got problem share sheet client email.


Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

javascript - Complex json ng-repeat -

jquery - Cloning of rows and columns from the old table into the new with colSpan and rowSpan -