PHP 从YELP API解析JSON

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PHP 从YELP API解析JSON相关的知识,希望对你有一定的参考价值。

$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); 

$obj = json_decode($yelpstring);// Convert JSON from yelp return string


	foreach($obj->businesses as $business):
	    echo "<img border=0 src='".$business->photo_url."'><br/>";
	    echo $business->name."<br/>";
	    echo $business->address1."<br/>";
	    
	    if( $business->address2 ){
	    	 echo $business->address2."<br/>";
	    };
	    
	    echo $business->city ."<br/>";
	    echo $business->state ."<br/>";
	    echo $business->zip ."<br/>";
	    echo $business->latitude ."<br/>";
	    echo $business->longitude ."<br/>";

	    echo "<hr>";
	endforeach;

以上是关于PHP 从YELP API解析JSON的主要内容,如果未能解决你的问题,请参考以下文章

Alamofire 获取请求和 JSON 响应(Yelp API)

Ionic 2 Yelp API

如何在邮递员上提出Yelp API GET请求?

从远程服务器解析 JSON 数据

php获得api返回的json数据后,如何解析?

如何在PHP中解析json