doushun4666 2018-05-16 03:13
浏览 1652
已采纳

CURL POST请求问题,获取curl_setopt()参数警告

Tried to send the post request with XML body using CURL but constantly getting following error,

Warning: curl_setopt() expects parameter 2 to be long, string given

I'm using following CURL request,

$ch = curl_init(POST_URL);

curl_setopt($ch, CURLOPT_MUTE, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml'));
curl_setopt($ch, CURLOPT_POSTFIELDS, "$xml");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

$output = curl_exec($ch);
curl_close($ch);
  • 写回答

1条回答 默认 最新

  • doulaozhang0238 2018-05-16 03:56
    关注

    I think the warning is referring to the CURLOPT_MUTE option. According to the docs, CURLOPT_MUTE was removed in cURL 7.15.5:

    CURLOPT_MUTE TRUE to be completely silent with regards to the cURL functions.
    Removed in cURL 7.15.5 (You can use CURLOPT_RETURNTRANSFER instead)

    When running your code (PHP 5.5.35, reporting all errors) I get a notice:

    Notice:  Use of undefined constant CURLOPT_MUTE - assumed 'CURLOPT_MUTE' 
    

    And then a warning:

    Warning: curl_setopt() expects parameter 2 to be long, string given
    

    So it seems that PHP interprets CURLOPT_MUTE as a string, hence the warning.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 求chat4.0解答一道线性规划题,用lingo编程运行,第一问要求写出数学模型和lingo语言编程模型,第二问第三问解答就行,我的ddl要到了谁来求了
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥15 maple软件,用solve求反函数出现rootof,怎么办?
  • ¥65 汇编语言除法溢出问题
  • ¥15 Visual Studio问题
  • ¥20 求一个html代码,有偿
  • ¥100 关于使用MATLAB中copularnd函数的问题
  • ¥20 在虚拟机的pycharm上
  • ¥15 jupyterthemes 设置完毕后没有效果