选项1:
$data= array(
"Code" => "abcde",
"Id" => "A007",
"RefNo" => "123456",
"UserName" => "QWE",
"UserEmail" => "qwe@gmail.com",
);
$url="https://testing.php";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result=curl_exec($ch);
curl_close ($ch);
echo $result;
}
选项 2:
<form method="post" action="https://testing.php">
<input type="hidden" value="abcde" name="Code">
<input type="hidden" value="A007" name="Id">
<input type="hidden" value="QWE" name="UserName">
<input type="hidden" value="qwe@gmail.com" name="UserEmail">
<input type="hidden" value="123456" name="RefNo">
<input type="submit" name="submit">
</form>
A和B有什么不同吗?因为我两者都试过了,但 curl 只能从 api 得到“失败”响应。