我正在尝试从 cellid 和 LAC 获得经纬度。
我一直在尝试使用Trouble with Sending JSON object over POST to Google Gears中提到的这个脚本来完成这个
如果有任何或任何替代方式,您能否指出任何错误?
我正在粘贴下面的代码
<?php
$urlstring="http://www.google.com/loc/json";
$ch=curl_init($urlstring);
$cell_towers = array();
$row=new stdClass();
$row->location_area_code=3311;
$row->mobile_network_code=71;
$row->cell_id=32751;
$row->mobile_country_code=404;
$cell_towers[]=$row;
$param = array(
'host'=> 'localhost',
'version' => '1.1.0',
'request_address' => true,
'cell_towers' => $cell_towers
);
$param_json=json_encode($param);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch,CURLOPT_POSTFIELDS,$param_json);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("application/json"));
$result=curl_exec($ch);
echo $result;
?>
这是更改后的代码(删除 url_encode)