你好,我正在从一台服务器传递一个JSON数组,比如www.example1.com,我想在另一台服务器上接收这个数据,比如www.example2.com/test.php。我已经使用cURL尝试了这一点,但我没有在接收端获取这些数据。位于发件人从一台服务器发送JSON并在另一台服务器上接收
$send_data = json_encode($myarray);
$request_url = 'www.example2.com/test.php';
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $request_url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, 'send_data='.$send_data);
$response = curl_exec($curl);
$curl_error = curl_error($curl);
curl_close($curl);
代码下面是我的代码
代码在接收
if(isset($_REQUEST['send_data'])){
$userinfo = json_decode($_REQUEST['send_data'],true);
print_r($userinfo);
}
如何在接收机端获取数据。
尝试呼应'$ response' – Ghost 2014-12-05 06:23:49
你应该做上述^ – Darren 2014-12-05 06:25:46
回声$回应给我的输出1 – 2014-12-05 06:26:10