Search code examples
phpjsonapiyelp

Yelp Fusion API - Pulling Specific Business Data Using PHP And JSON


I'm trying to figure out how to use the Yelp Fusion API with PHP to return the Yelp rating and location for a specific business.

I've looked for a code sample for the Yelp Fusion Business API in action, but I can't find one. I did find an example for the Yelp Fusion Search API (https://github.com/Yelp/yelp-fusion/blob/master/fusion/php/sample.php), but I'm not a developer and I'm struggling modifying it to work for my needs.

Can someone please show me how to develop a php file that will get the business data for a specific business (pick anyone or use the-crack-shack-encinitas) and how to echo these individual pieces of data (ratings and location)?

Thank you for your time and assistance.

Todd

High School Web Design Teacher and Life Long Learner

Documentation

https://www.yelp.com/developers/documentation/v3/business


Solution

  • I was able to get help on the Yelp GitHub Page https://github.com/Yelp/yelp-fusion/issues/202

    Below is the solution I cam up with and it works.

    $arr = json_decode($pretty_response);
    echo "Rating is - " . $arr->rating . "<br>" . "Address<br>" . $arr->location->display_address[0] . "<br>" . $arr->location->display_address[1];