【问题标题】:Yelp Business API 2.0 List Reviews with PHPYelp Business API 2.0 使用 PHP 列出评论
【发布时间】:2014-03-17 05:33:11
【问题描述】:

我正在使用 http://www.yelp.com/developers/documentation/v2/business 中记录的 Yelp Business API v2.0

我的目标是列出特定业务的三个评论,使用 PHP 进行 API 调用并检索 json。但是,我似乎只能使用 API 获取一条评论。我已经准备好循环并显示所有返回的评论的脚本。如何调用 API 来检索多条评论?

我尝试改用搜索 API,但它似乎也没有显示多条评论。

$unsigned_url = "http://api.yelp.com/v2/business/[the-business-name]";

...

// Handle Yelp response data
$response = json_decode($data, TRUE);

// for business API
foreach($response['reviews'] as $item) {
    print '<img src="' . $item['user']['image_url'] . '" alt="" /> ';
    print $item['user']['name'];
    print ' ';
    print '<img src="' . $item['rating_image_url'] . '" alt="" /><br/>';
    print $item['excerpt'];
}

【问题讨论】:

    标签: php json yelp


    【解决方案1】:

    很遗憾,API 不支持这一点。 你只会得到一个 List of up to 1 review snippet for the business.

    reviews 数组如下所示:

    [reviews] => Array
            (
                [0] => stdClass Object
                    (
                        [rating] => 5
                        [excerpt] => I spoke with Kenneth personally and he was the one to actually come and do the work.  Price he quoted to me on the phone was still the price I was charged -...
                        [time_created] => 1370286342
                        [rating_image_url] => http://s3-media1.ak.yelpcdn.com/assets/2/www/img/f1def11e4e79/ico/stars/v1/stars_5.png
                        [rating_image_small_url] => http://s3-media1.ak.yelpcdn.com/assets/2/www/img/c7623205d5cd/ico/stars/v1/stars_small_5.png
                        [user] => stdClass Object
                            (
                                [image_url] => http://s3-media4.ak.yelpcdn.com/assets/2/www/img/cc4afe21892e/default_avatars/user_medium_square.png
                                [id] => mFrv54j7_7bRdqlmb4WLsA
                                [name] => Nancy R.
                            )
    
                        [rating_image_large_url] => http://s3-media3.ak.yelpcdn.com/assets/2/www/img/22affc4e6c38/ico/stars/v1/stars_large_5.png
                        [id] => gFrVMC7pe0IW1lzpqfCwrg
                    )
    
            )
    

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-07-30
    • 1970-01-01
    • 2018-07-17
    • 1970-01-01
    相关资源
    最近更新 更多