日期:2014-05-18  浏览次数:20820 次

C#中使用GOOGLE API 基于手机基站LAC、CELL信息查地址和经纬度
C#中使用GOOGLE API 基于手机基站LAC、CELL信息查地址和经纬度
手上有PHP的方法,我想问下C#下有没有相关接口

<?php
/*
Desc: 提交请求参数 Request
version string google api 版本[必]
host string 服务器域名[必]
home_mobile_country_code integer 移动用户所属国家代号[选 中国460]
home_mobile_network_code integer 移动系统号码[选 默认0]
address_language string 反馈数据语言[选 中国 zh_CN]
radio_type string 信号类型[选 gsm|cdma|wcdma]
request_address bool 是否返回数据[必]
cell_towers object 移动基站参数对象[必]
cell_id integer 基站ID[必]
location_area_code integer 地区区域码[必]
age integer 使用好久的数据库[选 默认0表示使用最新的数据库]
timing_advance integer 距离单位
*/
  require(ROOT . 'include/curl.func.php');//加载封装好的curl函数库
  if(function_exists(json_decode)) {//判断服务器是否支持json_decode函数
  $post_data ='
{
  "version": "1.1.0",
  "host": "www.ipkaka.com",
  "home_mobile_country_code": "460",
  "home_mobile_network_code": "0",
  "address_language": "zh_CN",
  "radio_type": "gsm",
  "request_address": true ,
  "cell_towers":[
  {
  "cell_id": "2663",
  "location_area_code": "32902",
  "age": "0",
  "timing_advance": "5555"
  }
  ]
}
  ';
  $data = array(
  'url' => 'http://www.google.com/loc/json',//google API地址URL,注意请求一定要是Json格式
  'post' => $post_data,
  );
  $arr_post_result = ns_curl($data);//curl POST 过去,返回一个数组
  $result_html = $arr_post_result['html'];//API返回中有效东西,格式是JSON
  $result_code = $arr_post_result['http_code'];
  $obj_return_info = json_decode($result_html);//对Json解密,返回的是对象,请注意
  if(is_object($obj_return_info) && !empty($obj_return_info) && $result_code == 200) {
  object2array($obj_return_info); //object2array 递归对象转数组
  $arr_api_info = $obj_return_info;
  $obj_return_info = null;//杀掉内存中的无效变量
  $latitude = $arr_api_info['location']['latitude']; //纬度
  $longitude = $arr_api_info['location']['longitude']; //经度
  $country = $arr_api_info['location']['address']['country']; //国家名称
  $country_code = strtolower($arr_api_info['location']['address']['country_code']); //国家简写 CN
  $region = $arr_api_info['location']['address']['region']; //省
  $city = $arr_api_info['location']['address']['city']; //市
  $street = $arr_api_info['location']['address']['street']; //街道
  $accuracy = $arr_api_info['location']['accuracy']; //误差 单位meters
  $access_token = $arr_api_info['access_token']; //连接值
  print_r($longitude);
  }
  }
/*
Desc: google api 返回参数demo
Array
(
  [location] => Array
  (
  [latitude] => 30.644389
  [longitude] => 104.08439
  [address] => Arr