“晚风吹人醒 万事藏于心 
        我没说不公平 也没说苦 我说我知道了”
/**
     *
     * curl 提交数据
     *
     * @param unknown $url
     *            提交的链接
     * @param string $data
     *            如果有数据 提交类型为post
     * @return unknown
     */
    protected function https_request($url, $data = null) {
        $curl = curl_init ();
        if (class_exists ( '/CURLFile' )) { // php5.5跟php5.6中的CURLOPT_SAFE_UPLOAD的默认值不同
            curl_setopt ( $curl, CURLOPT_SAFE_UPLOAD, true );
        } else {
            if (defined ( 'CURLOPT_SAFE_UPLOAD' )) {
                curl_setopt ( $curl, CURLOPT_SAFE_UPLOAD, false );
            }
        }
        curl_setopt ( $curl, CURLOPT_URL, $url );
        curl_setopt ( $curl, CURLOPT_SSL_VERIFYPEER, FALSE );
        curl_setopt ( $curl, CURLOPT_SSL_VERIFYHOST, FALSE );
        if (! empty ( $data )) {
            curl_setopt ( $curl, CURLOPT_POST, 1 );
            curl_setopt ( $curl, CURLOPT_POSTFIELDS, $data );
        }
        curl_setopt ( $curl, CURLOPT_RETURNTRANSFER, 1 );
        $output = curl_exec ( $curl );
        curl_close ( $curl );
        return $output;
    }

 

posted on 2023-02-14 09:54  诗里刻画的影子  阅读(89)  评论(0编辑  收藏  举报