Posted By

jamesming on 11/18/08


Tagged

json yelp


Versions (?)

Who likes this?

4 people have marked this snippet as a favorite

corydeppen
jamesming
JN
morozgrafix


Parse JSON from YELP API


 / Published in: PHP
 

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

Also check out...

http://roshanbh.com.np/2008/10/creating-parsing-json-data-php.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;

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: JN on December 1, 2009

Good simple example. Thanks for putting it out there.

Posted By: wkasel on July 11, 2010

Curl is much, much faster almost 4x (http://stackoverflow.com/questions/555523/file-get-contents-vs-curl-what-has-better-performance)

You need to login to post a comment.