php curl simulation get request header set and

1. Analog get request file test_get.php

<PHP?
the error_reporting (E_ALL & E_NOTICE & ~ ~ E_DEPRECATED);
function the http_get (URL $)
{
    $ headers [] = "the Content-type: file application / X-WWW-form-urlencoded";
    $ headers [] = "Zoomkey- the Token-auth: 9CD0F0F60AFDF00 ";
    $ curl = curl_init (); // start a session cURL
    curl_setopt ($ curl, CURLOPT_URL to, $ URL);
    curl_setopt ($ curl, CURLOPT_HEADER, 0);
    curl_setopt ($ curl, CURLOPT_RETURNTRANSFER,. 1) ;
    curl_setopt ($ curl, CURLOPT_SSL_VERIFYPEER, to false); // skip certificate checking
    curl_setopt ($ curl, CURLOPT_SSL_VERIFYHOST, false ); // check whether there SSL encryption certificate from
    curl_setopt ($ curl, CURLOPT_HTTPHEADER, $ headers);
    $ = the curl_exec tmpInfo ($ curl);     
    // Close URL request
    curl_close ($ curl);
    return $tmpInfo;   
}
$url = 'http://www.test.com/test_get_info.php?name=123';
$resu = http_get($url);
echo $resu;

 

2. Test file test_get_info.php

<?php
error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED);
$name = $_GET['name'];
if($name)
{
    // echo "{\"name\":$name,\"s\":0}";
    // getallheaders()函数 php4 php5支持   apache支持 iis和nginx不支持
    foreach (getallheaders() as $name => $value) {
        echo "$name: $value\n";
    }
}else
{
    echo "{\"s\":-3}";
}

 

 

Guess you like

Origin www.cnblogs.com/loveufofbi/p/11820296.html