如何操作 google api php 客户端
how to manuplate the google api php client
如何通过传递图书的 isbn 号来操作此代码以获取图书的详细信息
$client = new \Google_Client();
$client->setApplicationName("BestBook");
$client->setAuthConfigFile('temp.json');
$client->addScope(\Google_Service_Drive::DRIVE);
$client->setDeveloperKey("AIzaSyD6OrKhhJiseBimFVJZ_7OV5tyPdg4LxZiY");
$service = new \Google_Service_Books($client);
$results = $service->volumes->listVolumes('Henry David Thoreau');
foreach ($results as $item) {
echo $item['volumeInfo']['imageLinks']['smallThumbnail'], "<br /> \n";
}
知道为什么当我通过一个 isbn 时它显示 10 个输出
请考虑 Google 书籍为您提供 ISBN_13 和 ISBN_10 的事实。考虑到这一点,您需要执行以下操作:
$client = new Google_Client();
$client->setApplicationName("BestBook");
$client->setDeveloperKey("asdfkjeriuIEWURkjfaskd");
$optParams = array(
'filter' => 'ebooks'//,
//'langRestrict' => 'es',
//'orderBy' => 'relevance'
);
$isbnNumber = 9781452052656;
$results = $service->volumes->listVolumes($isbnNumber, $optParams);
// HANDLE RESULT
foreach ($results as $item) {
if ($item['volumeInfo']['industryIdentifiers'][0]['identifier'] == $isbnNumber ) { // For ISBN_13 (for ISBN_10 use $item['volumeInfo']['industryIdentifiers'][1]['identifier'] )
echo " - ".utf8_decode($item['volumeInfo']['title']), "<br />";
}
}
顺便说一句,由于您访问的不是用户数据,而是应用程序数据,因此您不需要使用行 $client->addScope(\Google_Service_Drive::DRIVE);
和 $client->setAuthConfigFile('temp.json');
哦!我差点忘了!请不要 post 您的 API 密钥,因为那是敏感信息!
希望对您有所帮助!
如何通过传递图书的 isbn 号来操作此代码以获取图书的详细信息
$client = new \Google_Client();
$client->setApplicationName("BestBook");
$client->setAuthConfigFile('temp.json');
$client->addScope(\Google_Service_Drive::DRIVE);
$client->setDeveloperKey("AIzaSyD6OrKhhJiseBimFVJZ_7OV5tyPdg4LxZiY");
$service = new \Google_Service_Books($client);
$results = $service->volumes->listVolumes('Henry David Thoreau');
foreach ($results as $item) {
echo $item['volumeInfo']['imageLinks']['smallThumbnail'], "<br /> \n";
}
知道为什么当我通过一个 isbn 时它显示 10 个输出
请考虑 Google 书籍为您提供 ISBN_13 和 ISBN_10 的事实。考虑到这一点,您需要执行以下操作:
$client = new Google_Client();
$client->setApplicationName("BestBook");
$client->setDeveloperKey("asdfkjeriuIEWURkjfaskd");
$optParams = array(
'filter' => 'ebooks'//,
//'langRestrict' => 'es',
//'orderBy' => 'relevance'
);
$isbnNumber = 9781452052656;
$results = $service->volumes->listVolumes($isbnNumber, $optParams);
// HANDLE RESULT
foreach ($results as $item) {
if ($item['volumeInfo']['industryIdentifiers'][0]['identifier'] == $isbnNumber ) { // For ISBN_13 (for ISBN_10 use $item['volumeInfo']['industryIdentifiers'][1]['identifier'] )
echo " - ".utf8_decode($item['volumeInfo']['title']), "<br />";
}
}
顺便说一句,由于您访问的不是用户数据,而是应用程序数据,因此您不需要使用行 $client->addScope(\Google_Service_Drive::DRIVE);
和 $client->setAuthConfigFile('temp.json');
哦!我差点忘了!请不要 post 您的 API 密钥,因为那是敏感信息!
希望对您有所帮助!