简体   繁体   中英

How to get reviews from Google Books API with PHP

I'm struggeling with getting reviews back from the Google Books API in PHP. I've tried almost everything, but without much luck so far.

To try this, I've started with the examples provided by Google and modified them to test if I could get everything I need for my website.

I have managed to get back search results, use the volumeId of those results to get more details of one specific volume. So now I want to get the reviews belonging to that specific volume. The problem is that there's no function that will accept any volumeId parameter to specify the volume you want to have the reviews for.

The API file with the review data class you can find here:
apiBooksService.php
The whole project in SVN
The apiModel.php file you'll find under src->service.

Here's what I've already done:

This piece of code gives an full array of one specific volume. I've dumped this result on the screen and saw that all the fields are filled.

$volumeId = "IykGCqV1v20C";
$client = new apiClient();
$client->setApplicationName("My_Books_API_Example");
$service = new apiBooksService($client);
$optParamsVol = array( 'projection'=> 'full');
$results = $service->volumes->get($VolumeID);
var_dump($results);

After this I wanted to get the reviews of this volume.

$VolId = array('volumeId' => $VolumeID);
$review = new Review($VolId);

This gave the following result. As you can see, the field of the review class are all there, but they're all empty (apart from the volumeId I gave as input parameter). On the site of Google Books you can see that this same book (Avinash Kaushik, Webanalytics 2.0) has several reviews, so it shouldn't be empty.

object(Review)#16 (10) { ["rating"]=> NULL ["kind"]=> NULL ["author"]=> NULL ["title"]=> NULL ["volumeId"]=> string(12) "IykGCqV1v20C" ["content"]=> NULL ["source"]=> NULL ["date"]=> NULL ["type"]=> NULL ["fullTextUrl"]=> NULL }

Can anybody help me out with this issue?

Best regards,

Patrick

I'm not sure that you can, all the API mentions is to get a specific user's reviews, not all reviews for a certain title. The only thing mentioned by staff on google forums is that thay may implement it, or to try this:

http://files.zend.com/help/Zend-Framework/zend.gdata.books.html#zend.gdata.books.retrieving_annotations

People are definitely wondering the same thing: http://books.google.com/support/partner/bin/search.py?hl=en&forum=1&query=reviews+more%3Aforum

Sorry I couldn't be of more help!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM