Base Station Cloud Interface Development Example (PHP call base Station Data interface)

Source: Internet
Author: User

Base Station cloud Platform interface call instance, using curl to quickly access the base station cloud platform data interface, to obtain the base station data, and through JSON to parse the array data.

<?php/* Base Station Cloud Interface Call Instance Qq:742631333*/header ("Content-type:text/html;charset=utf-8"); UTF8 code $apikey= "";    Set apikey$mnc=0;    0 Mobile 1 Unicom $lac=2;   Large area code $cell=2; Cell number $apiurl= "http://www.jizhanyun.com/api/?mnc= $mnc &lac= $lac &cell= $cell &ishex=0&apikey={$      Apikey} "; $data =curl_file_get_contents ($apiurl); $json =json_decode ($data); $code = $json->code;      Status number $about= $json->about;    Status description if ($code = = ' 001 ') {$data = $json->data[0];         Data set $lng= $data->lng;         Latitude $lat= $data->lat;       Longitude $glng= $data->glng;       Google Latitude $glat= $data->glat; Google Longitude $address= $data->address; Address description//output echo "<b> Base Station cloud location result:</b><br/>"; echo "Latitude:". $lng. " <br/> "; echo" Longitude: ". $lat." <br/> "; echo" Google Latitude: ". $glng." <br/> "; echo" Google Longitude: ". $glat." <br/> "; echo" Address Description: ". $address." <br/> ";} Else{echo "return Result:". $about;}   HTTP request functions function curl_file_get_contents ($durl) {$ch = Curl_init ();   curl_setopt ($ch, Curlopt_url, $durl); curl_setopt ($ch, curlopt_tImeout, 10);   curl_setopt ($ch, curlopt_useragent, _useragent_);   curl_setopt ($ch, Curlopt_referer,_referer_);   curl_setopt ($ch, Curlopt_returntransfer, 1);   $r = curl_exec ($ch);   Curl_close ($ch); return $r; }?>

  

Base Station Cloud Interface Development Example (PHP call base Station Data interface)

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.