Código PHP:
<?
$data = array("name" => "Hagrid", "age" => "36");
$data_string = json_encode($data);
$ch = curl_init('https://172.16.19.60/curl.php');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_VERBOSE, TRUE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data_string))
);
//$result = curl_exec($ch);
if( ! $result = curl_exec($ch)){
echo curl_error($ch);
}
echo "<pre>";var_dump(json_decode($result));echo "</pre>";
?>
Probé algo así pero nada
Código PHP:
<?php
$array=$data_string;
$string=json_encode($array);
echo $string;
?>