cURL not working with POST data

前端 未结 3 1449
感情败类
感情败类 2021-01-27 20:50

I am trying to debug this, but I\'ve had no luck. Am I sending the POST data correctly?

if (isset($_POST[\'chrisBox\'])) {

$curl = curl_init();
curl_setopt($cur         


        
3条回答
  •  心在旅途
    2021-01-27 21:19

    CURLOPT_POSTFILEDS requires an urlencoded string or an array as param. Read PHP Manual curl_setopt. Have changed your example, now it uses an urlencoded string.

    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, 'chrisBox=' . urlencode($_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;
    }
    

提交回复
热议问题