php,curl模拟post请求,获取不到数据 20
这是我写的代码,结果获取不到任何数据。如果我用网上提供的post测试工具,填写同样的参数,就可以获取到数据,大神们帮我看一下哪出错了<?phpheader("Conten...
这是我写的代码,结果获取不到任何数据。
如果我用网上提供的post测试工具,填写同样的参数,就可以获取到数据,大神们帮我看一下哪出错了
<?php
header ( "Content-type: text/html; charset=utf-8" );
$url="http://wxk0721.m.zloveyouhui.com/index/tqg/tqg";
$post_data = array ("start_at" => "2017-10-14 10:00:00","page_no" => "1");
$header = array(
'Accept' => '*/*',
'Accept-Encoding' => 'gzip, deflate',
'Accept-Language' => 'zh-CN,zh;q=0.8',
'Connection' => 'keep-alive',
'Content-Length'=>'42',
'Content-Type' => 'application/x-www-form-urlencoded; charset=UTF-8',
'Host' => 'wxk0721.m.zloveyouhui.com',
'Origin' => 'http://wxk0721.m.zloveyouhui.com',
'Referer' => 'http://wxk0721.m.zloveyouhui.com/tqg',
'User-Agent' => 'Mozilla/5.0 (iPhone; CPU iPhone OS 9_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13B143 Safari/601.1',
'X-Requested-With' => 'XMLHttpRequest',
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
$output = curl_exec($ch);
echo $output;
?> 展开
如果我用网上提供的post测试工具,填写同样的参数,就可以获取到数据,大神们帮我看一下哪出错了
<?php
header ( "Content-type: text/html; charset=utf-8" );
$url="http://wxk0721.m.zloveyouhui.com/index/tqg/tqg";
$post_data = array ("start_at" => "2017-10-14 10:00:00","page_no" => "1");
$header = array(
'Accept' => '*/*',
'Accept-Encoding' => 'gzip, deflate',
'Accept-Language' => 'zh-CN,zh;q=0.8',
'Connection' => 'keep-alive',
'Content-Length'=>'42',
'Content-Type' => 'application/x-www-form-urlencoded; charset=UTF-8',
'Host' => 'wxk0721.m.zloveyouhui.com',
'Origin' => 'http://wxk0721.m.zloveyouhui.com',
'Referer' => 'http://wxk0721.m.zloveyouhui.com/tqg',
'User-Agent' => 'Mozilla/5.0 (iPhone; CPU iPhone OS 9_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13B143 Safari/601.1',
'X-Requested-With' => 'XMLHttpRequest',
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
$output = curl_exec($ch);
echo $output;
?> 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询