Created
January 30, 2016 00:06
-
-
Save mstaples/66c5773cd153fca57048 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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