curl_exec 不执行

浏览:2841 发布日期:2017/07/11 分类:求助交流
测试参数都正常,$xmldata是xml流,curl_exec权限也是开启可用的,但是执行到curl_exec之后,就什么也不输出    $data = array(
            'mch_appid' => $this->config['APPID'],
            'mchid'     => $this->config['MCHID'],
            'nonce_str' => self::getNonceStr(),
            //'device_info' => '1000',
            'partner_trade_no' => $trade_no, //商户订单号,需要唯一
            'openid'    => $openid,
            'check_name'=> 'NO_CHECK',     //OPTION_CHECK不强制校验真实姓名, FORCE_CHECK:强制 NO_CHECK:
            //'re_user_name' => 'jorsh', //收款人用户姓名
            'amount'    => $money * 100, //付款金额单位为分
            'desc'      => $desc,
            'spbill_create_ip' => get_client_ip()
        );
        
        $data['sign'] = self::makeSign($data);

        $xmldata = self::array2xml($data);
        $url = 'https://api.mch.weixin.qq.com/mmpaymkttransfers/promotion/transfers';
                
        $res = self::curl_post_ssl($url, $xmldata);

    
    
    public function curl_post_ssl($url, $xmldata, $second=30,$aHeader=array()){
        
        if(!function_exists('curl_init')) exit('Need to open the curl extension');

        $ch = curl_init();
        //超时时间
        curl_setopt($ch, CURLOPT_TIMEOUT,$second);
        curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $second);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
        curl_setopt($ch, CURLOPT_USERAGENT, 'PHP-SDK OAuth2.0');
        //这里设置代理,如果有的话
        //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); // 从证书中检查SSL加密算法是否存在
        
        //以下两种方式需选择一种
        
        //第一种方法,cert 与 key 分别属于两个.pem文件
        //默认格式为PEM,可以注释
        curl_setopt($ch, CURLOPT_SSLCERTTYPE,'PEM');
        curl_setopt($ch, CURLOPT_SSLCERT,APP_ROOT_PATH.$this->config['SSLCERT_PATH']);
        curl_setopt($ch, CURLOPT_SSLKEYTYPE,'PEM');
        curl_setopt($ch, CURLOPT_SSLKEY,APP_ROOT_PATH.$this->config['SSLKEY_PATH']);
        
        //第二种方式,两个文件合成一个.pem文件
        //curl_setopt($ch,CURLOPT_SSLCERT,getcwd().'/all.pem');
        $aHeader = array("Content-Type: text/html", "Content-length: ".strlen($xmldata));
        if( count($aHeader) >= 1 ){
            curl_setopt($ch, CURLOPT_HTTPHEADER, $aHeader);
        }
        curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
        curl_setopt($ch, CURLOPT_POST, TRUE);
        curl_setopt($ch, CURLOPT_POSTFIELDS,$xmldata);
        //到这里正常
        $data = curl_exec($ch);
        //到这里以后程序不输出任何东西
        var_dump($data);
        //$data为空
        
        var_dump($curlInfo);
        var_dump($xmldata);
        
        exit;
        
        if($data){
            curl_close($ch);
            return $data;
        }
        else { 
            $error = curl_errno($ch);
            echo "call faild, errorCode:$error\n"; 
            curl_close($ch);
            return false;
        }
    }
,vardump('111');居然也不显示!!不知何故,请大侠帮忙看一看

最佳答案
评论( 相关
后面还有条评论,点击查看>>