Google图书列表数量结果

时间:2017-04-10 10:32:05

标签: php codeigniter oop google-api-php-client

我正在使用Codeigniter和Google API Client Library for PHP并尝试通过ISBN查找返回单本图书的详细信息。

它有效并且我能够检索数据,但由于某种原因,我收到了多个结果。例如,我现有的代码是:

控制器

public function index() {
    $client = new Google_Client();
    $client->setApplicationName("Client_Library_Examples");
    $client->setDeveloperKey("MyKey");
    $service = new Google_Service_Books($client);
    $results = $service->volumes->listVolumes('0751538310');
        $data = array(
        'gresult'   => $results 
        );
    $this->load->view('template/header');
    $this->load->view('item_list', $data);
    $this->load->view('template/footer');
}

查看

<?php 
   foreach ($gresult as $item) {
       echo $item['volumeInfo']['title'], "<br /> \n";
   }
?>

返回以下内容:

Panic
Swiss News
Simply Irresistible
Ein perfekter Freund

direct Google URL会返回类似的结果。

知道为什么会这样吗?我只需要第一个结果。

由于

0 个答案:

没有答案