dsfo22654 2011-10-25 21:50
浏览 35

如何使用PHP从Google Books API获取评论

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

  • 写回答

1条回答 默认 最新

报告相同问题?

悬赏问题

  • ¥20 易康econgnition精度验证
  • ¥15 线程问题判断多次进入
  • ¥15 msix packaging tool打包问题
  • ¥28 微信小程序开发页面布局没问题,真机调试的时候页面布局就乱了
  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致