当前位置:Gxlcms > PHP教程 > PHP微信开发支付失败curl_setopt()

PHP微信开发支付失败curl_setopt()

时间:2021-07-01 10:21:17 帮助过:14人阅读

PHP Warning: curl_setopt() expects parameter 2 to be long, string given in E:\wwwroot\pay3\WxPayPubHelper\WxPayPubHelper.php on line 821
/**
     *  作用:通过curl向微信提交code,以获取openid
     */
    function getOpenid()
    {
        $url = $this->createOauthUrlForOpenid();
        //初始化curl
        $ch = curl_init();
        //设置超时
        curl_setopt($ch, CURLOP_TIMEOUT, $this->curl_timeout);  821行代码
        echo $this->curl_timeout;
        exit;
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,FALSE);
        curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,FALSE);
        curl_setopt($ch, CURLOPT_HEADER, FALSE);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
        //运行curl,结果以jason形式返回
        $res = curl_exec($ch);
        curl_close($ch);
        //取出openid
        $data = json_decode($res,true);
        $this->openid = $data['openid'];
        return $this->openid;
    }

回复内容:

PHP Warning: curl_setopt() expects parameter 2 to be long, string given in E:\wwwroot\pay3\WxPayPubHelper\WxPayPubHelper.php on line 821
/**
     *  作用:通过curl向微信提交code,以获取openid
     */
    function getOpenid()
    {
        $url = $this->createOauthUrlForOpenid();
        //初始化curl
        $ch = curl_init();
        //设置超时
        curl_setopt($ch, CURLOP_TIMEOUT, $this->curl_timeout);  821行代码
        echo $this->curl_timeout;
        exit;
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,FALSE);
        curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,FALSE);
        curl_setopt($ch, CURLOPT_HEADER, FALSE);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
        //运行curl,结果以jason形式返回
        $res = curl_exec($ch);
        curl_close($ch);
        //取出openid
        $data = json_decode($res,true);
        $this->openid = $data['openid'];
        return $this->openid;
    }

curl_setopt($ch, CURLOPT_TIMEOUT, $this->curl_timeout); 821行代码 //字母写错了

人气教程排行