php调用返回json的webservice
<?php
$dbsrvr="localhost";
function get_recommend_media_by_id_ex($url)
{
global $dbsrvr;
$product_id = "4fbf28f148e65f7220c5f870";
$url = 'http://'.$dbsrvr.':8080/lct-shopping/api/shopping/recommenditems/'.$product_id;
$json = file_get_contents($url);
$list=json_decode($json,true);
return $list;
}
?>
例子中的
$url = 'http://'.$dbsrvr.':8080/lct-shopping/api/shopping/recommenditems/'.$product_id;
是要我访问的url,使用json_decode解析json格式的返回数据。