可能重复:
使用 cURL 传递 $_POST 值
我正在尝试使用 curl 将从表单发送到中间验证页面的 $_POST 值传递到另一台服务器进行处理......然后返回我们的服务器以显示成功页面。
这是我所拥有的:
unset($_POST['recaptcha_challenge_field']);
unset($_POST['recaptcha_response_field']);
$params = $_POST;
foreach ( $params as $key => $value) {
$post_items[] = $key . '=' . $value;
}
$post_string = implode ('&', $post_items);
$curl_connection =
curl_init('http://server.somedomain.net/about/spit.php');
curl_setopt($curl_connection, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($curl_connection, CURLOPT_USERAGENT,
"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)");
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl_connection, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl_connection, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($curl_connection, CURLOPT_POSTFIELDS, $post_string);
$result = curl_exec($curl_connection);
print_r(curl_getinfo($curl_connection));
echo curl_errno($curl_connection) . '-' .
curl_error($curl_connection);
//close the connection
curl_close($curl_connection);
据我所知,数据似乎在那里并且格式正确,但它没有发送到服务器。知道这有什么问题吗?我有点困惑。
戴夫