Home  >  Article  >  Backend Development  >  php curl怎么以get方式提交

php curl怎么以get方式提交

WBOY
WBOYOriginal
2016-06-06 20:19:421355browse

例如:http://localhost/openapi/holiday/Line/Query/GetLineComment?AllianceId=12&DigitalSign=7aeac3d1c621c30c144f23b5a498bbda01895b70&ReqTime=2013-09-02 16:23:49.929

这个地址用get怎么提交

回复内容:

例如:http://localhost/openapi/holiday/Line/Query/GetLineComment?AllianceId=12&DigitalSign=7aeac3d1c621c30c144f23b5a498bbda01895b70&ReqTime=2013-09-02 16:23:49.929

这个地址用get怎么提交

curl 默认就是以 GET 提交的,如果为POST提交,请检查是否配置了 curl_setopt($c, CURLOPT_POST, 1); 这个参数

<code>    /**
     * GET 请求
     * @param string $url
     */
    private function http_get($url){
        $oCurl = curl_init();
        if(stripos($url,"https://")!==FALSE){
            curl_setopt($oCurl, CURLOPT_SSL_VERIFYPEER, FALSE);
            curl_setopt($oCurl, CURLOPT_SSL_VERIFYHOST, FALSE);
            curl_setopt($oCurl, CURLOPT_SSLVERSION, 1); //CURL_SSLVERSION_TLSv1
        }
        curl_setopt($oCurl, CURLOPT_URL, $url);
        curl_setopt($oCurl, CURLOPT_RETURNTRANSFER, 1 );
        //增加代理
        //curl_setopt($oCurl, CURLOPT_PROXY, HTTP_PROXY_IP_PORT);
        $sContent = curl_exec($oCurl);
        $aStatus = curl_getinfo($oCurl);
        curl_close($oCurl);
        if(intval($aStatus["http_code"])==200){
            return $sContent;
        }else{
            return false;
        }
    }</code>

file_get_contents

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn