php json 解析不出来,接收到的json解析不了,必须用php解析,该如何解决

接收到的json解析不了,必须用php解析

function sendPost($url,$postData){

$postdata = http_build_query($postData);

$options = array(

'http' => array(

'method' => 'POST',

'header' => 'Content-type:application/x-www-form-urlencoded',

'content' => $postdata,

'timeout' => 15 * 60 // 超时时间(单位:s)

)

);

$context = stream_context_create($options);

$result = file_get_contents($url, false, $context);

return $result;

}

$url = "http://chepiao.sinaapp.com/api.php?act=remain";

$data = array(

"date"=>"20131220",

"startStation"=>"北京",

"arriveStation"=>"天津"

);

$result = sendPost($url, $data);

$obj = json_decode($result);

$result就是返回来的数据,就是解析不了,用json_decode($result);解析成的是NULL

php中文网:公益在线php培训,帮助PHP学习者快速成长!

Copyright 2014-2020 https://www.php.cn/ All Rights Reserved | 苏ICP备2020058653号-1e6cebb680dfe320dad7e62bd6442c3a6.gif

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值