时间:2021-07-01 10:21:17 帮助过:4人阅读
$arrayData = array("name" => "Hagrid", "age" => "36");
$sendJsonData = json_encode($arrayData);
$ch = curl_init('http://127.0.0.1/jietu/test.php');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $sendJsonData);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($sendJsonData))
);
$ret = curl_exec($ch);
if($ret == '00'){
成功了执行的代码;
}elseif($ret == '11'){
登录失败
}