<span style= "FONT-SIZE:18PX;" >view.html<form action= "view.php" method= "post" ><input type= ' text ' name= ' view ' value= ' Pinyin of Sights ' >< Input type= "Submit" name= "Submit" value= "View attraction Information" ></form>view.php<?php# set the Code header (' content-type:text/ Html;charset=utf-8 '), #判断接收数据if (Isset ($_post[' submit ')) {#接收景点拼音 $view = $_post[' view ']; #使用接口 $str = "http:// api.map.baidu.com/telematics/v3/travel_attractions?id={$view}&ak=0h6m5r2mbkuipa1zwdg0zbng "; #获取信息 $data = File _get_contents ($STR); #获取xml信息 $data = simplexml_load_string ($data);//Var_dump ($data); #遍历景点信息foreach ($data) Result as $val) {var_dump ($val); Echo ' <pre> '; Echo ' attraction name: '. $val->name. " <br> "Echo ' Attractions Description: '. $val->description." <br> "; Echo ' fare: '. $val->ticket_info->price." <br> "; Echo ' Other matters: '. $val->ticket_info->attention->item->description. ' <br> ';}} </span>
Car Networking API Php+xml (1) Attractions Enquiry