最佳答案
我尝试了 在 POST 请求中的 PHP 发送请求,认为它可能对我有用。我的代码如下:
$sub_req_url = "http://localhost/index1.php";
$ch = curl_init($sub_req_url);
$encoded = '';
// include GET as well as POST variables; your needs may vary.
foreach($_GET as $name => $value) {
$encoded .= urlencode($name).'='.urlencode($value).'&';
}
foreach($_POST as $name => $value) {
$encoded .= urlencode($name).'='.urlencode($value).'&';
}
// chop off last ampersand
$encoded = substr($encoded, 0, strlen($encoded)-1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $encoded);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_exec($ch);
curl_close($ch);
从 index.php文件和 index2.php是在同一目录中的另一个文件,当我打开页面,我得到以下错误在我的 error.log文件:
[ Sat Dec 1815:24:532010][ error ][ client: : 1] PHP Fatal error: 在第5行/var/www/testing1/index.PHP 中调用未定义的函数 curl _ init ()
我想做的是有一个发送邮寄请求的预订表单。然后我想处理文章的价值,并再次发送文章请求到贝宝。