簡體   English   中英

Yelp Business API 2.0列出使用PHP的評論

[英]Yelp Business API 2.0 List Reviews with PHP

我正在使用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'];
}

不幸的是,API不支持此功能。 您最多只能獲得List of up to 1 review snippet for the businessList 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
                )

        )

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM