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 基于单片机数字电压表电路组成及框图
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 unity第一人称射击小游戏,有demo,在原脚本的基础上进行修改以达到要求
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line