获取电子表格Google电子表格api PHP的标题



我正试图获得电子表格名称。但这行不通。有人能帮帮我吗?我正在使用php和谷歌电子表格和谷歌驱动器api:

function getSheetTitle($spreadsheetID){
$client = new Google_Client();
$client->setApplicationName('Sheets');
$client->setScopes([Google_Service_Sheets::SPREADSHEETS]);
$client->setAccessType('offline');
$client->setAuthConfig(GOOGLE_CREDENTIALS);

$client = GoogleClientSheet();
$service = new Google_Service_Sheets($client);

$worksheetSheets = $service->spreadsheets->get($spreadsheetID);
return $worksheetSheets->getTitle();
}

只需添加getProperties()->getTitle()

function getSheetTitle($spreadsheetID){
$client = new Google_Client();
$client->setApplicationName('Sheets');
$client->setScopes([Google_Service_Sheets::SPREADSHEETS]);
$client->setAccessType('offline');
$client->setAuthConfig(GOOGLE_CREDENTIALS);

$client = GoogleClientSheet();
$service = new Google_Service_Sheets($client);

$worksheetSheets = $service->spreadsheets->get($spreadsheetID);
return $worksheetSheets->getProperties()->getTitle();
}

相关内容

  • 没有找到相关文章

最新更新