dsa111111 2011-08-05 16:38
浏览 52
已采纳

如何使用php从LAC-CELLId获取lat和long数据?

This code return null value. Value is: {}

I checked it, CURL is enabled but still it returns null -> {}. Do you get the results?

Please help me asap.

PHP code is blow:

$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("Content-Type: application/json"));
$result=curl_exec($ch);
echo $result; 
  • 写回答

1条回答 默认 最新

  • duanrao3371 2011-08-05 16:56
    关注

    Try replacing the new stdClass() with a simple array().

    Also did you try to echo $param_json? Is the data properly formatted?

    Finally, I'm surprised the POSTFIELDS is the whole JSON data. Are you sure it shouldn't be something like curl_setopt($ch,CURLOPT_POSTFIELDS, array("data" => $param_json))?

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私