Php 在cURL中处理JSON响应

Php 在cURL中处理JSON响应,php,json,curl,null,Php,Json,Curl,Null,我使用cURL处理JSON响应,但是它只返回NULL。我不明白我哪里做错了 这是我的密码: <?php $data = array('name' => 'Hagrid','age' => '36'); $bodyData = array('json' => json_encode($data)); $bodyStr = http_build_query($bodyData); $url = 'htt

我使用
cURL
处理
JSON
响应,但是它只返回
NULL
。我不明白我哪里做错了

这是我的密码:

    <?php
        $data = array('name' => 'Hagrid','age' => '36');

        $bodyData = array('json' => json_encode($data));
        $bodyStr = http_build_query($bodyData);
        $url = 'http://bulk10.co.in/curl/index.php';

        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded','Content-Length: '.strlen($bodyStr)));
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $bodyStr);

        $result = curl_exec($ch);
        echo $result;
    ?>

index.php:

<?php
    $order_info = json_decode($_POST['json']);
    var_dump($order_info);
?>


有人能帮我解释为什么我得到
NULL
响应吗?

这是我当前服务器返回
NULL
的问题。其中一个Stack用户检查了这个代码,并告诉他得到了完美的答案。然后我在不同的服务器上检查了这个,现在它工作得非常好。

你在
$\u POST['json']
(没有
json\u decode
)上得到什么了吗?如果json无法解码或编码的数据深度超过递归限制,则返回NULL。不,它只是显示为空…抱歉,一切正常,我只是在本地主机上做了一个测试。您应该在web服务器或web缓存上配置错误。您得到了什么输出?
object(stdClass)[1]public'name'=>string'Hagrid'(length=6)public'age'=>string'36'(length=2)
on
echo$result