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] => Array
                (
                    [country] => 中国
                    [country_code] => CN
                    [region] => 四川省
                    [city] => 成都市
                    [street] => 黄伞巷
                )
 
            [accuracy] => 723
        )
 
    [access_token] => 2:mqs0Jw83vIzz0OG2:pbCXuys2oe6pJgLy
)
*/
?>这是PHP的   我用的是C# 有人知道怎么弄不?

解决方案 »

  1.   

    http://topic.csdn.net/u/20091216/10/b73f33ba-831d-4ff5-b727-83d586615b78.html?seed=191105229&r=63902908
      

  2.   

    楼主,能不能分享一下你的C#代码呢,我也是用C#的,谢谢了。[email protected]
      

  3.   

    按PHP中格式组织JSON串  发给服务器  再接收下JSON  解析JSON就OK了
      

  4.   

    是不是讲先写一个方法,方法里面包含的就是上面的PHP方法,然后往里面传入LAC,CELL,解析完成以后再根据返回的经纬度进行定位啊????
      

  5.   

    按PHP这里组织的JSON格式,在.NET中照着做上发的JSON,上发后,接收GOOGLE下发的JSON,并在.NET解析这个JSON就可以了,下发的JSON中会有经纬度和地址信息