使用下面的脚本,我正在尝试登录网页,然后执行一个通常由按钮后面的Ajax脚本触发的帖子。登录工作正常,但我无法模拟Ajax操作。感谢您的协助
<?php
ini_set('max_execution_time', 0);
$submit_url = "LOGINURL";
$submit_url2 = "OVERVIEWURL";
$postdata = array('action.id' => urlencode('al_regid_162'),
'action.component.id' => urlencode('form_aanvraag_filter'),
'action.section.id' => urlencode('section1'));
$curl = curl_init();
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC ) ;
curl_setopt($curl, CURLOPT_USERPWD, "USERNAME:PASSWORD");
curl_setopt($curl, CURLOPT_SSLVERSION,3);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_URL, $submit_url);
$data = curl_exec($curl);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $postdata);
curl_setopt($curl, CURLOPT_URL, $submit_url2);
$data = curl_exec($curl);
print($data);
curl_close($curl);
?>
答案 0 :(得分:1)
1.在curl脚本中将CURLOPT_FOLLOWLOCATION设置为true。
在卷曲代码后使用file_get_contents('your_url/WEBPAGE/pimplus/service');
。(仅适用于GET方法)
答案 1 :(得分:0)
尝试做:
curl_setopt($ch,CURLOPT_URL,$submit_url2); curl_setopt($ch,CURLOPT_POST,count($postdata)); curl_setopt($ch,CURLOPT_POSTFIELDS,$postdata);
希望有所帮助