<?php
$username="xxx@126.com";//$_POST["username"];
$password="xxx";//$_POST["password"];
$message="1";//$_POST["message"];
if($message!=""){
updateRenren($message,$username,$password,0);
echo $message;
}
function updateRenren($status,$renren_username,$renren_password,$tried_times){
if($tried_times>=3){
return false;
}
$cookie_jar=tempnam('./cookie','renren');
$ch=&getCurl($cookie_jar,"POST","http://www.renren.com/ajaxLogin/login");
curl_setopt($ch,CURLOPT_POSTFIELDS,'email='.urlencode($renren_username).'&password='.urlencode($renren_password).'&origURL=http%3A%2F%2Fwww.renren.com%2FHome&domain=renren.com&key_id=1&captcha_type=web_login&_rtk=90ae5f12');
$str=&sendAndResult($ch);
/*
$pattern="/get_`check:'([^']+)'/";
preg_match($pattern,$str,$matches);
$get_check=$matches[1];
$ch=&getCurl($cookie_jar,"POST","http://status.renren.com/doing/update.do");
curl_setopt($ch,CURLOPT_POSTFIELDS,'c='.urlencode($status).'&raw='.urlencode($status).'&isAtHome=1&publisher_form_ticket='.$get_check.'&requestToken='.$get_check);
curl_setopt($ch,CURLOPT_REFERER,'http://status.renren.com/ajaxproxy.htm');
$ret=&sendAndResult($ch);
if(strpos($ret,"{\"allMsg\":")===0){
echo "[Renren] succeed\n";
}else{
echo "[Renren] failed\n";
updateRenren($status,$renren_username,$renren_password,$tried_times+1);
}
*/
$ch = &getCurl($cookie_jar,"GET","http://www.renren.com/123456");
$ret = &sendAndResult($ch);
}
function &getCurl($jar,$method,$url){
$ch=curl_init();
curl_setopt($ch,CURLOPT_COOKIEJAR,$jar);
curl_setopt($ch,CURLOPT_COOKIEFILE,$jar);
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_FOLLOWLOCATION,TRUE);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,TRUE);
curl_setopt($ch, CURLOPT_USERAGENT,"Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.2.8) Gecko/20100722 Firefox/3.6.8");
//curl_setopt($ch,CURLOPT_VERBOSE,true);
if($method=="POST"){
curl_setopt($ch,CURLOPT_POST,TRUE);
}else{
curl_setopt($ch,CURLOPT_POST,FALSE);
}
return $ch;
}
function &sendAndResult(&$ch){
$str=curl_exec($ch);
curl_close($ch);
unset($ch);
echo $str;
return $str;
}
本想用c++实现登陆到人人网,和访问用户主页。无奈,cookie设置有问题,那就用 php测试下。因此有了如上的代码:
2304

被折叠的 条评论
为什么被折叠?



