php登陆人人网和用户主页


<?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测试下。因此有了如上的代码:

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值