无法处理请求"cURL"


Could not process the request "cURL"

我创建了一个使用curl发送xml数据的函数,当我点击该函数时,我的浏览器上出现了一条消息"无法处理请求",不明白代码有什么问题,下面是我的函数:

    function otp_data_send($xmlblock='',$url='' ){
   $otp_xml_data = htmlentities($xmlblock);
   $headers = array(
   "Content-type: text/xml",
   "Content-length: " . strlen($otp_xml_data),
   "Connection: close",
    );
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL,$url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_TIMEOUT, 10);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $otp_xml_data);
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
    $data = var_dump(curl_exec($ch));
    // print_r($data);exit;
    echo $data;
    if(curl_errno($ch))
       print curl_error($ch);
    else
       curl_close($ch);
 }

并在另一个函数中调用该函数。请帮助

试着得到一个更详细的错误

function otp_data_send($xmlblock='',$url='' ){
   $otp_xml_data = htmlentities($xmlblock);
   $headers = array(
   "Content-type: text/xml",
   "Content-length: " . strlen($otp_xml_data),
   "Connection: close",
    );
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL,$url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_TIMEOUT, 10);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $otp_xml_data);
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
    if(curl_exec($ch) === false) {
        return 'Curl error: [' . curl_errno($ch) . '] ' . curl_error($ch);
    } else {
        return 'Operation completed without any errors';
    }
}
echo otp_data_send(...);

更新1

function otp_data_send($xmlblock='',$url='' ){
   $otp_xml_data = htmlentities($xmlblock);
   $headers = array(
   "Content-type: text/xml",
   "Content-length: " . strlen($otp_xml_data),
   "Connection: close",
    );
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL,$url);
    curl_setopt($ch, CURLOPT_HEADER, 1);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_TIMEOUT, 10);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $otp_xml_data);
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
    $output = curl_exec($ch);
    $info = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    curl_close($ch);
    return '[' . $info . ']' . $output;
}
echo otp_data_send(...);