Parsing JSON response using PHP for Yelp API -
Parsing JSON response using PHP for Yelp API -
i can't seem parse info sent yelp api. here's output: http://www.coroomer.com/apartments/yelp.php.
here segment of code having problem with:
// send yelp api phone call $ch = curl_init(); curl_setopt($ch, curlopt_url, $signed_url); curl_setopt($ch, curlopt_returntransfer, 1); curl_setopt($ch, curlopt_connecttimeout, 30); $response = curl_exec($ch); curl_close($ch); // handle yelp response info $obj = json_decode($response,true); // print debugging //print_r($obj); echo var_dump($obj); if (isset($bus)) { foreach($obj[businesses] $bus){ echo $bus[name]; echo $bus[reviews]; } }
the problem can't correctly "formatted" output. formatted in looks review threads on yelp. help appreciated.
it's not clear asking. however...
1. prepare warnings , notices first. not seek access arrays without single or double quotes around indexes, because php seek resolve them constants. lead to:
a. slower runtime
b. headaches, if constant exists index
change code:
foreach($obj[businesses] $bus){ echo $bus[name]; echo $bus[reviews];
to
foreach($obj['businesses'] $bus){ echo $bus['name']; echo $bus['reviews'];
2. dump doesn't have array index businesses
, trying iterate on here?
php json api parsing yelp
Comments
Post a Comment