php登陸人人網和使用者首頁

來源:互聯網
上載者:User
<?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測試下。因此有了如上的代碼:

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.