Php+simplexml Car Networking API usage (1) Attractions Enquiry

Source: Internet
Author: User

<span style= "color: #993399;" > #html页面 Submit Query Information view.html</span><body><form action= "view.php" method= "post" ><input type= ' Text ' name= ' view ' value= ' Pinyin ' ><input type= "submit" name= "Submit" value= "View attractions Information" ></form><span style= "COLOR: #993399;" >view.php page for XML processing </span><?php# set coded 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=<span style= "color: #993399;" >0H6m5R2mBkUipA1zwDg0zBnG</span> "; #该密匙在百度libs云注册后获得 # Get information $data = file_get_contents ($STR); #获取xml信息 $data = simplexml_load_string ($data); <span style= " Color: #993399; " > #遍历景点信息 parsing according to the XML structure of the </span>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> ';}}

Php+simplexml Car Networking API usage (1) Attractions Enquiry

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.