php - Dealing with JSON Response in cURL -
i'm dealing json response using curl, return null. don't understand i'm doing wrong ?
here code:
<?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); ?> can 1 me why i'm getting null response ?
its problem current server returning null. 1 of stack user checked code , told he's getting perfect answer. i've checked in different server, working absolutely fine.
Comments
Post a Comment