• curl---get||post


       
      get

       private function getcalldata($concurrent){ //这是用get方式传值 //这是用get方式传值 //这是用get方式传值 //这是用get方式传值 //这是用get方式传值 //这是用get方式传值 //这是用get方式传值 //这是用get方式传值 $resurl=$this->url.'&Number='.$concurrent; $res=$this->http_post($resurl, ''); return $res; } /** * 发送https请求,需要开启php_curl * Enter description here ... * @param unknown_type $url * @param unknown_type $data */ private function http_post($url, $data){ $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE); curl_setopt($curl, CURLOPT_POST, 1); curl_setopt($curl, CURLOPT_POSTFIELDS, $data); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); $output = curl_exec($curl); if (curl_errno($curl)) { return 'Error: '.curl_error($curl); } curl_close($curl); return $output; }
      post
     
       private function getcalldata($concurrent){
            //这是用post方式传值
            $resurl= '1111111';
         $data['data'] = json_encode($resurt);
     
         $res=$this->http_post($resurl, );
         return $res;
        }
    
    
    
    /**
         * 发送https请求,需要开启php_curl
         * Enter description here ...
         * @param unknown_type $url
         * @param unknown_type $data
         */
        private function http_post($url, $data){
            $curl = curl_init();
            curl_setopt($curl, CURLOPT_URL, $url);
            curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
            curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE);
            curl_setopt($curl, CURLOPT_POST, 1);
            curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
            curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
            $output = curl_exec($curl);
            if (curl_errno($curl)) {
                return 'Error: '.curl_error($curl);
            }
            curl_close($curl);
            return $output;
        }
  • 相关阅读:
    软件质量属性简述
    浅谈MVC架构
    SOA整理
    程序员的自我修养阅读笔记3
    程序员的自我修养阅读笔记2
    程序员的自我修养阅读笔记1
    架构漫谈阅读笔记3
    架构漫谈阅读笔记2
    Weather APP
    php通过==和!==比较NULL和''结果均为真
  • 原文地址:https://www.cnblogs.com/CWQPHP/p/10488696.html
Copyright © 2020-2023  润新知