足球游戏_中国足彩网¥体育资讯$

php采用curl模仿登录人人网发布动态的方法
来源:易贤网 阅读:502 次 日期:2014-11-13 14:05:55
温馨提示:易贤网小编为您整理了“php采用curl模仿登录人人网发布动态的方法”,方便广大网友查阅!

说到php中模仿登录很多人第一时间会想到curl函数系列了,这个没错本例子也是使用curl模仿登录之后再进行动态发布,原理也简单我们只要抓取人人网的登录信息,然后再由curl post登录数据上去就可以了。

具体代码如下:

代码如下:

$rconfig = pdo_fetch("SELECT * FROM ".tablename("eduTwo_renren")." WHERE weid = :weid",array(':weid'=>$_W['weid']));

$cookie_file = dirname(__FILE__)."/renren.cookie";

$login_url = 'http://passport.renren.com/PLogin.do';

$post_fields['email'] = $rconfig['rusername'];

$post_fields['password'] = $rconfig['rpassword'];

$post_fields['origURL'] = 'http%3A%2F%2Fhome.renren.com%2FHome.do';

$post_fields['domain'] = 'renren.com';

$ch = curl_init($login_url);

curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.1.5) Gecko/20091102 Firefox/3.5.5');

curl_setopt($ch, CURLOPT_HEADER, 0);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

curl_setopt($ch, CURLOPT_MAXREDIRS, 1);

curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);

curl_setopt($ch, CURLOPT_AUTOREFERER, 1);

curl_setopt($ch, CURLOPT_POST, 1);

curl_setopt($ch, CURLOPT_POSTFIELDS, $post_fields);

curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file);

$content = curl_exec($ch);

$info = curl_getinfo($ch);

curl_close($ch);

//var_dump($info);exit;

//匹配用户的ID

$send_url='http://www.renren.com/home';

$ch = curl_init($send_url);

curl_setopt($ch, CURLOPT_HEADER, 0);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file);

curl_exec($ch);

$info = curl_getinfo($ch);

curl_close($ch);

//$uid = "305115027";

//获取token和rtk

$send_url=$info['redirect_url'];

$ch = curl_init($send_url);

curl_setopt($ch, CURLOPT_HEADER, 0);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file);

$tmp = curl_exec($ch);

curl_close($ch);

preg_match_all("/get_check:'(.*?)',get_check_x:'(.*?)',/is",$tmp,$arr);

preg_match_all("/'ruid':'(.*?)',/is",$tmp,$utmp);

//var_dump($utmp);exit;

$token = $arr[1][0];//1121558104

$rtk = $arr[2][0];//e9a9cb2

$uid = $utmp[1][0];

//echo $token;exit;

//发布信息

$poststr['content'] = $_GPC['content'].$rconfig['tail'];

$poststr['withInfo'] = '{"wpath":[]}';

$poststr['hostid:'] = $uid;

$poststr['privacyParams'] = '{"sourceControl": 99}';

$poststr['requestToken'] = $token;

$poststr['_rtk'] = $rtk;

$poststr['channel'] = "renren";

$head = array(

'Referer:http://shell.renren.com/ajaxproxy.htm',

'X-Requested-With:XMLHttpRequest',

);

$ch = curl_init("");

curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.1.5) Gecko/20091102 Firefox/3.5.5');

curl_setopt($ch,CURLOPT_HTTPHEADER,$head);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

curl_setopt($ch, CURLOPT_MAXREDIRS, 1);

curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);

curl_setopt($ch, CURLOPT_AUTOREFERER, 1);

curl_setopt($ch, CURLOPT_POST, 1);

curl_setopt($ch, CURLOPT_POSTFIELDS, $poststr);

curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file);

$content = curl_exec($ch);

curl_close($ch);

//echo $content;exit;

$data = json_decode($content,true);

if($data["code"] == "0"){

echo "发布成功!";

}else{

echo "shit !!!";

}

最后就发布成功了,当然前面的数据库需要自己写一个吧,非常的简单的一个记录库也是你要发布的信息。录数据上去就可以了。

中国足彩网信息请查看IT技术专栏

中国足彩网信息请查看网络编程
由于各方面情况的不断调整与变化,易贤网提供的所有考试信息和咨询回复仅供参考,敬请考生以权威部门公布的正式信息和咨询为准!
关于我们 | 联系我们 | 人才招聘 | 网站声明 | 网站帮助 | 非正式的简要咨询 | 简要咨询须知 | 加入群交流 | 手机站点 | 投诉建议
工业和信息化部备案号:滇ICP备2023014141号-1 足球游戏_中国足彩网¥体育资讯$ 滇公网安备53010202001879号 人力资源服务许可证:(云)人服证字(2023)第0102001523号
云南网警备案专用图标
联系电话:0871-65317125(9:00—18:00) 获取招聘考试信息及咨询关注公众号:hfpxwx
咨询QQ:526150442(9:00—18:00)版权所有:易贤网
云南网警报警专用图标