Get data on API yelp

1.4k Views Asked by At

I have to use the Yelp API in php to create a small box with reviews from yelp for my company, I never use it, and I read the doc this morning. I understand how t works, but I don't understand how to get the data from the response {'businesses': [{'address1': '466 Haight St', 'address2': '', 'address3': '', etc...... }} My url is simple, I just enter the name of the business like: $url="http://api.yelp.com/business_review_searchterm=$term&location=$city%2A%20CA&ywsid=$key"; with all the var ok.

Can you help me please, I just want to know how to get this data Thanks

1

There are 1 best solutions below

3
On

You should use PHP's json_decode function to turn this into a PHP object.

$response = json_decode("{'businesses': [{'address1': '466 Haight St', 'address2': '', 'address3': '', etc...... }}");

// to view structure
print_r($response);

// access the first business address1
print $response->businesses[0]->address1;