• php curl header头中添加请求信息


      $header  = array(
                'x-api-key:'.'b8602c0361111415a221759cdeb9e636',
                'Content-Type:'.'application/x-www-form-urlencoded; charset=UTF-8'
            );
    

      

        /**
         * @param $url
         * @param null $data
         * @return bool|string
         */
        public function http_request($url, $data = null, $header = null){
    
            $curl = curl_init();
            if(!empty($header)){
                curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
                curl_setopt($curl, CURLOPT_HEADER, 0);//返回response头部信息
            }
    
            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_HTTPGET, 1);
                curl_setopt($curl, CURLOPT_POSTFIELDS,http_build_query($data));
            }
    
            curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
            $output = curl_exec($curl);
            curl_close($curl);
            return $output;
        }
    

      

  • 相关阅读:
    P1312 [NOIP2011 提高组] Mayan 游戏
    Codeforces Round 736
    CF487E Tourists
    荏苒
    数论
    [NOI2009] 二叉查找树 题解
    元素
    线性基
    杂录
    SQL中关于Join、Inner Join、Left Join、Right Join、Full Join、On、 Where区别
  • 原文地址:https://www.cnblogs.com/cnn2017/p/11607152.html
Copyright © 2020-2023  润新知