php get请求自定义 header

曹え 5811 发布于:2022-08-30 07:12:36

<?php
 header('Access-Control-Allow-Origin:*');
 header('Access-Control-Allow-Headers:Origin, No-Cache, X-Requested-With, If-Modified-Since, Pragma, Last-Modified, Cache-Control, Expires, Content-Type, X-E4M-With, Authorization,security');
 header('Content-Type: application/json');

    $options = array(  
      'http' => array(
        'header' => 'Referer: //请求头部 
        'timeout' => 600 // 超时时间(单位:s)  
      )  
    );  
     
    $url = "http://1.cn";  // 请求地址
    $context = stream_context_create($options);  
    $result = file_get_contents($url, false, $context);  

    echo $result;


觉得有用请点个赞吧!
0 1467