chentailin
function weather_request($curl,$https=true,$method=\'\',$data=null){
        $ch=curl_init();
      //  $user_agent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/15.0.874.121 Safari/535.2";  
        curl_setopt($ch, CURLOPT_URL, $curl);//设置URL
        curl_setopt($ch, CURLOPT_HEADER, false);//设置头信息

        curl_setopt($ch, CURLOPT_ENCODING, "");//如果数据被压缩  则加这项
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);//只获取页面内容 不输出
        if($https){
            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);//不做服务器认证
            curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);//不做客户端认证
        }
        if($method==\'post\'){
            curl_setopt($ch, CURLOPT_POST, true);
            curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
        }
        $str=curl_exec($ch);
       // dump($str);
        curl_close($ch);
      //  $str=mb_convert_encoding($str, \'UTF-8\', \'UTF-8,GBK,GB2312,BIG5\');
        return $str;

}

 

分类:

技术点:

相关文章:

  • 2021-12-27
  • 2021-12-27
  • 2021-12-27
  • 2021-12-27
  • 2021-12-27
  • 2021-12-27
  • 2021-12-27
  • 2021-12-27
猜你喜欢
  • 2021-12-27
  • 2021-12-27
  • 2021-12-27
  • 2021-12-27
  • 2021-12-27
  • 2022-12-23
相关资源
相似解决方案