php curl get请求带请求头cookie

function http_get($url){
   $headers[] = "cookie: abtest_env=product; zsxq_access_token=FE522175-5950-1279-9CF5-0EF91484D2C8_4FB9C5CF8F4EACD4"
   $headers[] = "origin: https://wx.zsxq.com";
   $headers[] = "referer: https://wx.zsxq.com/";
   $headers[] = "user-agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36";
   $headers[] = "x-request-id: e668374b0-c3bd-ea72-196b-ad79dd99274";
   $headers[] = "x-signature: 09a83d3bfa109d48b7d32bb20050cbb8404f5295";
   $headers[] = "x-timestamp:".time();
   $curl = curl_init(); // 启动一个CURL会话
   curl_setopt($curl, CURLOPT_URL, $url);
   curl_setopt($curl, CURLOPT_HEADER, 0);
   curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
   curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); // 跳过证书检查
   curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);  // 从证书中检查SSL加密算法是否存在
   curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
   $tmpInfo = curl_exec($curl);
   //关闭URL请求
   curl_close($curl);
   return $tmpInfo;   
}

未经允许不得转载:任鹏个人博客 » php curl get请求带请求头cookie

赞 (0) 打赏

评论 0

取消
  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏