我正在使用 curl 完成三项任务。也就是说,登录我的测试站点,进入我们输入文本的表单并获取隐藏的随机session_id
数,设置第三个 curl 请求以发布带有 session_id 的消息。但是这里只能执行前两个请求。该消息未发布。
索引.php
$ch = curl_init();
$url = 'http://webforum.com';
include 'a.php';
$url = 'http://webforum.com/add_message.php';
include 'C.php';
preg_match_all('|name="session_id" value="(.*?)"|',$store,$tks);
$token = $tks[1][0];
$postf = 'session_id='.$token.'&add=mga&text=TAPPOUT&submit=Submit';
include 'c.php';
?>
c.php
$cookie_file_path="cookies.txt";
$agent="Nokia-Communicator-WWW-Browser/2.0 (Geos 3.0 Nokia-9000i)";
$headers[]="Accept: */*";
$headers[]="Connection: Keep-Alive";
curl_setopt($ch,CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch,CURLOPT_HEADER,0);
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_COOKIEFILE,$cookie_file_path);
curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,0);
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,false);
curl_setopt($ch,CURLOPT_USERAGENT,$agent);
curl_setopt($ch,CURLOPT_POST,1);
curl_setopt($ch,CURLOPT_POSTFIELDS,$postf);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_FOLLOWLOCATION,1);
curl_setopt($ch,CURLOPT_COOKIEJAR,$cookie_file_path);
$store = curl_exec($ch);
?>
谁能找出问题所在?