PFinal\Wechat\SDK\Redpack\Helper::curl_post_ssl PHP Method

curl_post_ssl() public method

public curl_post_ssl ( $url, $vars, $second = 30, $aHeader = [] )
    function curl_post_ssl($url, $vars, $second = 30, $aHeader = array())
    {
        $ch = curl_init();
        //超时时间
        curl_setopt($ch, CURLOPT_TIMEOUT, $second);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        //这里设置代理,如果有的话
        //curl_setopt($ch,CURLOPT_PROXY, '10.206.30.98');
        //curl_setopt($ch,CURLOPT_PROXYPORT, 8080);
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
        //以下两种方式需选择一种
        //第二种方式,两个文件合成一个.pem文件
        //curl_setopt($ch,CURLOPT_SSLCERT,getcwd().'/all.pem');
        //第一种方法,cert 与 key 分别属于两个.pem文件
        curl_setopt($ch, CURLOPT_SSLCERT, $this->sslCert);
        //curl_setopt($ch, CURLOPT_SSLKEY, $this->sslKey);
        //curl_setopt($ch, CURLOPT_CAINFO,$this->caInfo);
        if (!empty($this->sslKey)) {
            curl_setopt($ch, CURLOPT_SSLKEY, $this->sslKey);
        }
        if (!empty($this->caInfo)) {
            curl_setopt($ch, CURLOPT_CAINFO, $this->caInfo);
        }
        if (count($aHeader) >= 1) {
            curl_setopt($ch, CURLOPT_HTTPHEADER, $aHeader);
        }
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $vars);
        $data = curl_exec($ch);
        if ($data) {
            curl_close($ch);
            return $data;
        } else {
            $error = curl_errno($ch);
            //echo "call faild, errorCode:$error\n";
            curl_close($ch);
            return false;
        }
    }