Parse JSON from YELP API


/ Published in: PHP
Save to your folder(s)

Also check out...

http://roshanbh.com.np/2008/10/creating-parsing-json-data-php.html


Copy this code and paste it in your HTML
  1. $yelpstring = file_get_contents("http://api.yelp.com/business_review_search?category=bars&lat=".$latitude."&long=".$longitude."&radius=25&num_biz_requested=100&ywsid=<your yelp account id>", true);
  2.  
  3. $obj = json_decode($yelpstring);// Convert JSON from yelp return string
  4.  
  5.  
  6. foreach($obj->businesses as $business):
  7. echo "<img border=0 src='".$business->photo_url."'><br/>";
  8. echo $business->name."<br/>";
  9. echo $business->address1."<br/>";
  10.  
  11. if( $business->address2 ){
  12. echo $business->address2."<br/>";
  13. };
  14.  
  15. echo $business->city ."<br/>";
  16. echo $business->state ."<br/>";
  17. echo $business->zip ."<br/>";
  18. echo $business->latitude ."<br/>";
  19. echo $business->longitude ."<br/>";
  20.  
  21. echo "<hr>";
  22. endforeach;

URL: http://groups.google.com/group/yelp-developer-support/browse_thread/thread/d52aa7033b3e7dbd#

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.