カールポストにContent-Typeパラメータを導入したいのですが、インターネットで多くの方法を試しましたが、まだ機能しません。
<?php$headers = array( 'User-Agent' => 'Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9) Gecko/2008052906 Firefox/3.0', 'Referer' => 'http://www.163.com');$url='http://walktest.sinaapp.com/env.php';$ch = curl_init($url);curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);curl_setopt($ch, CURLOPT_HEADER, true);curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 120);curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);//curl_setopt($ch, CURLOPT_REFERER, 'http://www.baidu.com');$result = curl_exec($ch);curl_close($ch);echo $result;?>
$headers = array( 'User-Agent' => 'Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9) Gecko/2008052906 Firefox/3.0', 'Referer' => 'http://www.163.com','Content-type'=>'content-type');$url='http://walktest.sinaapp.com/env.php';$ch = curl_init($url);>
もし私が間違いを犯したとしても、私をサポートしてくれなかった他の人を責めることはできません。
$headers = array( 'User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9) Gecko/2008052906 Firefox/3.0', 'Referer: http://www.163.com',);$url='http://walktest.sinaapp.com/env.php';$ch = curl_init($url);curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);curl_setopt($ch, CURLOPT_HEADER, true);curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 120);curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);//curl_setopt($ch, CURLOPT_REFERER, 'http://www.baidu.com');$result = curl_exec($ch);curl_close($ch);echo $result;
HTTP/1.1 200 OK Server: nginx Date: Sun, 06 Dec 2015 01:33:43 GMT Content-Type: text/html Transfer-Encoding: chunked Connection: keep-alive Via: 10.67.21.26 Set-Cookie: saeut=117.70.161.80.1449365623790278; path=/; max-age=311040000 firefox3HTTP_USER_AGENT:Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9) Gecko/2008052906 Firefox/3.0HTTP_ACCEPT:*/*REQUEST_METHOD:GETHTTP_USER_AGENT:Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9) Gecko/2008052906 Firefox/3.0HTTP_REFERER:http://www.163.com
もし私が間違いを犯したとしても、私をサポートしてくれなかった他の人を責めることはできません。
$headers = array( 'User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9) Gecko/2008052906 Firefox/3.0', 'Referer: http://www.163.com',);$url='http://walktest.sinaapp.com/env.php';$ch = curl_init($url);curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);curl_setopt($ch, CURLOPT_HEADER, true);curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 120);curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);//curl_setopt($ch, CURLOPT_REFERER, 'http://www.baidu.com');$result = curl_exec($ch);curl_close($ch);echo $result;
HTTP/1.1 200 OK Server: nginx Date: Sun, 06 Dec 2015 01:33:43 GMT Content-Type: text/html Transfer-Encoding: chunked Connection: keep-alive Via: 10.67.21.26 Set-Cookie: saeut=117.70.161.80.1449365623790278; path=/; max-age=311040000 firefox3HTTP_USER_AGENT:Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9) Gecko/2008052906 Firefox/3.0HTTP_ACCEPT:*/*REQUEST_METHOD:GETHTTP_USER_AGENT:Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9) Gecko/2008052906 Firefox/3.0HTTP_REFERER:http://www.163.com