Mr. B
Mr. B

Reputation: 2787

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

Upvotes: 1

Views: 1471

Answers (3)

Mr. B
Mr. B

Reputation: 2787

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];

Upvotes: 1

contempoinc
contempoinc

Reputation: 25

There isn't much out there yet but this is what I've used to convert my API v2 code from https://github.com/Yelp/yelp-fusion/blob/master/fusion/php/sample.php

Upvotes: 0

Atul Jindal
Atul Jindal

Reputation: 976

I am not sure, but i suspect based on my understanding you might not be using authentication for calling APIs. There might be issues with client_id, token and client secret. Please go through this documentation

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

and scroll to section Get an access token

Upvotes: 0

Related Questions