标题: curl求教
时间: 2015-10-20
<?php
$discuz_url = 'https://hu60.cn/wap/';//论坛地址
$login_url = $discuz_url .'read.php?id=login&u=index.php';//登录页地址
$post_fields = array();
$post_fields['name'] = "冰封";
$post_fields['pass'] = 'xx';
$ch = curl_init($login_url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$contents = curl_exec($ch);
curl_close($ch);
//POST数据,获取COOKIE,cookie文件放在网站根目录下
//dirname(__FILE__)."/pic.cookie";
echo $cookie_file = dirname(__FILE__)."/cookie.txt";//tempnam('./','cookie');
$ch = curl_init($login_url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_fields);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file);
print_r($ch);
curl_exec($ch);
curl_close($ch);
exit();
//取到了关键的cookie文件就可以带着cookie文件去模拟回帖
$send_url = $discuz_url."read.php?id=bbs_xiehf";
$ch = curl_init($send_url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file);
$contents = curl_exec($ch);
curl_close($ch);
$post_data = array();
$post_data['sid'] = '-';
$post_data['bkid'] = "59";
$post_data['tzid'] = "39871";
$post_data['nr'] = 'xxxxxxxxxxxxx';
$ch = curl_init($send_url);
curl_setopt($ch, CURLOPT_REFERER, $send_url); //伪装REFERER
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 0);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
$contents = curl_exec($ch);
curl_close($ch);
//清理cookie文件
//unlink($cookie_file);
?>
『回复列表(3|隐藏机器人聊天)』