Skip to content

Instantly share code, notes, and snippets.

@mstaples
Created January 30, 2016 00:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mstaples/66c5773cd153fca57048 to your computer and use it in GitHub Desktop.
Save mstaples/66c5773cd153fca57048 to your computer and use it in GitHub Desktop.
<?php
namespace GoogleSpreadsheetAPI\entity;
include_once ( __DIR__ . '/../lib/autoload.php' );
use Google\Spreadsheet\SpreadsheetService as ParentSpreadsheetService;
use Google\Spreadsheet\ServiceRequestFactory;
use SimpleXMLElement;
class SpreadsheetService extends ParentSpreadsheetService
{
/**
* Fetches a list of spreadsheets from google drive.
*
* @return SpreadsheetFeed
*/
public function getSpreadsheets()
{
return new SpreadsheetFeed(
ServiceRequestFactory::getInstance()->get('feeds/spreadsheets/private/full')
);
}
/**
* Fetches a single spreadsheet from google drive by id if you decide
* to store the id locally. This can help reduce api calls.
*
* @param string $id the url of the spreadsheet
*
* @return \GoogleSpreadsheetAPI\entity\Spreadsheet
*/
public function getSpreadsheetById($id)
{
return new Spreadsheet(
new SimpleXMLElement(
ServiceRequestFactory::getInstance()->get('feeds/spreadsheets/private/full/'. $id)
)
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment