wow*_*uzz 0 php debugging curl
我试图调试这个,但我没有运气.我是否正确发送了POST数据?
if (isset($_POST['chrisBox'])) {
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, "http://www.associates.com/send-email-orders.php");
curl_setopt($curl, CURLOPT_POST, TRUE);
curl_setopt($curl, CURLOPT_POSTFIELDS, $_POST['chrisBox']);
curl_setopt($curl, CURLOPT_HEADER, FALSE);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, FALSE);
curl_setopt($curl, CURLOPT_VERBOSE, TRUE);
$ex = curl_exec($curl);
echo 'email';
$email = true;
}
Run Code Online (Sandbox Code Playgroud)
$_POST请求中发送的参数必须采用以下形式:
key=value&foo=bar
Run Code Online (Sandbox Code Playgroud)
您可以使用PHP的http-build-query函数.它将从数组创建一个查询字符串.
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($_POST));
Run Code Online (Sandbox Code Playgroud)
如果您只想传递一个参数,则仍需要将其包装在数组或对象中.
$params = array(
'stack'=>'overflow'
);
http_build_query($params); // stack=overflow
Run Code Online (Sandbox Code Playgroud)