Wordpress卷曲发送默认内容类型

时间:2016-06-28 05:25:02

标签: php wordpress curl

我正在使用wordpress网站。我想通过php curl请求点击api。我已经在本地编写了代码,它运行正常。然后我在实时服务器上传了完全相同的代码。它找不到http_code 404页面。这是我的代码:

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "strJSON=" . json_encode($php_array));
curl_setopt($ch,CURLOPT_USERAGENT,'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13');
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$server_output = curl_exec($ch);
$cInfo = curl_getinfo($ch);
curl_close($ch);

以下是实际网站上$cInfo的print_r:

[url] => url
[content_type] => text/html; charset=UTF-8
[http_code] => 404
[header_size] => 402
[request_size] => 556
[filetime] => -1
[ssl_verify_result] => 0

以下是本地网站上$cInfo的打印件:

[url] => url
[content_type] => 
[http_code] => 200
[header_size] => 519
[request_size] => 450
[filetime] => -1
[ssl_verify_result] => 0
[redirect_count] => 0

该网站基于wordpress。区别在于content_typehttpcode

0 个答案:

没有答案