Reputation: 77
I am using the Yelp Business API v2.0 as documented at http://www.yelp.com/developers/documentation/v2/business
My goal is to list three reviews of a specific business, using PHP to make the API call and retrieve the json. I seem to only be able to fetch one review, however, with the API. I have the script prepared to loop and display all reviews returned. How can I call the API to retrieve more than one review?
I tried using the search API instead but it didn't seem to show multiple reviews either.
$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'];
}
Upvotes: 2
Views: 3791
Reputation: 2699
Unfortunately the API does not support this.
You only get a
List of up to 1 review snippet for the business
.
The reviews array looks like this:
[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
)
)
Upvotes: 1