我正在使用此庫https://github.com/asimlqt/php-google-spreadsheet-client與Google的電子表格api進行交互。php-google-spreadsheet-client getByTitle返回null
使用提供了相當多因爲是例子,我有這樣的WIP代碼:
$request = new Google\Spreadsheet\Request($access['access_token']);
$serviceRequest = new Google\Spreadsheet\DefaultServiceRequest($request);
Google\Spreadsheet\ServiceRequestFactory::setInstance($serviceRequest);
$spreadsheetService = new Google\Spreadsheet\SpreadsheetService();
$spreadsheetFeed = $spreadsheetService->getSpreadsheets();
var_dump($spreadsheetFeed);
$spreadsheet = $spreadsheetFeed->getByTitle('a spreadsheet');
echo "<h1>Start spreadsheet single feed</h1>";
var_dump($spreadsheet);
的最後一行是意外打印空。 我希望有人熟悉圖書館可以將我推向正確的方向。
順便說一句,這是什麼$ spreadsheetFeed轉儲顯示:
object(Google\Spreadsheet\SpreadsheetFeed)#263 (2) {
["xml":"Google\Spreadsheet\SpreadsheetFeed":private]=>
object(SimpleXMLElement)#200 (5) { ["id"]=> string(63)
"https://spreadsheets.google.com/feeds/spreadsheets/private/full"
["updated"]=> string(24) "2014-04-22T15:41:32.296Z"
["category"]=> object(SimpleXMLElement)#244 (1) {
["@attributes"]=>
array(2) {
["scheme"]=> string(43) "http://schemas.google.com/spreadsheets/2006"
["term"]=> string(55) "http://schemas.google.com/spreadsheets/2006#spreadsheet"
}
}
["title"]=> string(100) "Available Spreadsheets - <redacted!>"
["link"]=> array(3) {
[0]=> object(SimpleXMLElement)#243 (1) {
["@attributes"]=> array(3) {
["rel"]=> string(9) "alternate"
["type"]=> string(9) "text/html" ["href"]=> string(22) "http://docs.google.com"
}
}
[1]=> object(SimpleXMLElement)#245 (1) {
["@attributes"]=> array(3) {
["rel"]=> string(37) "http://schemas.google.com/g/2005#feed"
["type"]=> string(20) "application/atom+xml"
["href"]=> string(63) "https://spreadsheets.google.com/feeds/spreadsheets/private/full"
}
}
[2]=> object(SimpleXMLElement)#246 (1) {
["@attributes"]=> array(3) {
["rel"]=> string(4) "self"
["type"]=> string(20) "application/atom+xml"
["href"]=> string(63) "https://spreadsheets.google.com/feeds/spreadsheets/private/full"
}
}
}
}
["storage":"ArrayIterator":private]=> array(0) {
}
}
它出現在所有這些是非常令人困惑,因爲我確認所需的電子表格存在早些時候成功在不包含任何電子表格代碼通過驅動器API。很明顯,我使用的兩個庫之間存在某種差異,但沒有記錄,但我不知道要調試它。
驅動庫是這裏的谷歌室內一個https://github.com/google/google-api-php-client
那麼你是如何將文件創建更改爲.xls? – Piero
指出您更改了文件創建非常無益。您應該正確描述解決方案,以真正幫助社區。 – Laci