聚合数据的移动联通基站接口的php完整代码实例
本代码是基于聚合数据的移动联通基站查询API实现的基站定位功能
<?php // +---------------------------------------------------------------------- // | JuhePHP [ NO ZUO NO DIE ] // +---------------------------------------------------------------------- // | Copyright (c) 2010-2015 http://juhe.cn All rights reserved. // +---------------------------------------------------------------------- // | Author: Juhedata <info@juhe.cn> // +---------------------------------------------------------------------- //---------------------------------- // 聚合数据-基站查询API调用示例代码 //---------------------------------- header('Content-type:text/html;charset=utf-8'); $apiurl = 'http://v.juhe.cn/cell/get'; //基站接口url $mnc = '0';//移动基站:0 联通基站:1 默认:0 $cell = '28655';//大区号 $lac = '17695';//小区号 $key = '52a0ee009932b35054********'; //您申请的appkey $params = "mnc={$mnc}&cell={$cell}&lac={$lac}&key={$key}"; $content = juhecurl($apiurl,$params); if(!$content){ echo "网络错误,请求接口失败"; }else{ $result = json_decode($content,true); $error_code = $result['error_code']; if($error_code == 0){ //成功请求到数据 $data = $result['result']['data'][0]; /* "MCC":"460", "MNC":"1", "LNG":"120.721423", //gps坐标:经度 "LAT":"31.29854", //gps坐标:纬度 "O_LNG":"120.72577772352", //高德坐标:经度 "O_LAT":"31.296529947917", //高德坐标:纬度 "PRECISION":"1101", //基站覆盖半径 "ADDRESS":"江苏省苏州市吴中区金鸡湖大道368号" //基站地址 */ print_r($data); }else{ echo $result['reason']."(".$result['error_code'].")"; } } function juhecurl($url,$params=false,$ispost=0){ $httpInfo = array(); $ch = curl_init(); curl_setopt( $ch, CURLOPT_HTTP_VERSION , CURL_HTTP_VERSION_1_1 ); curl_setopt( $ch, CURLOPT_USERAGENT , 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.118 Safari/537.36' ); curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT , 30 ); curl_setopt( $ch, CURLOPT_TIMEOUT , 30); curl_setopt( $ch, CURLOPT_RETURNTRANSFER , true ); if( $ispost ) { curl_setopt( $ch , CURLOPT_POST , true ); curl_setopt( $ch , CURLOPT_POSTFIELDS , $params ); curl_setopt( $ch , CURLOPT_URL , $url ); } else { if($params){ curl_setopt( $ch , CURLOPT_URL , $url.'?'.$params ); }else{ curl_setopt( $ch , CURLOPT_URL , $url); } } $response = curl_exec( $ch ); if ($response === FALSE) { //echo "cURL Error: " . curl_error($ch); return false; } $httpCode = curl_getinfo( $ch , CURLINFO_HTTP_CODE ); $httpInfo = array_merge( $httpInfo , curl_getinfo( $ch ) ); curl_close( $ch ); return $response; }
Copy after login
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article
Assassin's Creed Shadows: Seashell Riddle Solution
3 weeks ago
By DDD
What's New in Windows 11 KB5054979 & How to Fix Update Issues
2 weeks ago
By DDD
Where to find the Crane Control Keycard in Atomfall
3 weeks ago
By DDD
Saving in R.E.P.O. Explained (And Save Files)
1 months ago
By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics
CakePHP Tutorial
1386
52

