如何在请求头里添加自定属性,
但需要在请求头里添加自定属性.例如 mimi=3322
如何定义这个?
$mimi = md5(3322);
$h = array("mimi:{$mimi}");
curl_setopt($ch,CURLOPT_HTTPHEADER,$h);
$result = curl_exec ($ch);
var_dump($result);
这样吗?可我测试来测试去,发送的请求都找不到自己定义的属性哦!~!~
------解决思路----------------------
<br />$url = 'http://www.example.com/server.php';<br />$mimi = md5(3322);<br /><br />$header = array(<br /> "mimi:{$mimi}"<br />);<br /><br />$ch = curl_init();<br />curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);<br />curl_setopt($ch, CURLOPT_URL, $url);<br />curl_setopt($ch, CURLOPT_HTTPHEADER, $header);<br />$response = curl_exec($ch);<br />if($error=curl_error($ch)){<br /> die($error);<br />}<br />curl_close($ch);<br /><br />echo $response;<br />
<br />$data = isset($_SERVER['HTTP_MIMI'])? $_SERVER['HTTP_MIMI'] : '';<br />echo $data;<br />