Php curl simulates logon to Renren to publish dynamic instances

Source: Internet
Author: User
Tags curl

Sample code

The code is as follows: Copy code


$ 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 ['url url'] = '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;
// Match the user 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 ";
// Obtain the token and mnsx.

$ 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
$ Scn = $ arr [2] [0]; // e9a9cb2
$ Uid = $ utmp [1] [0];
// Echo $ token; exit;
// Publish information
$ Poststr ['content'] =_ _ GPC ['content']. $ rconfig ['tail'];
$ Poststr ['withinfo'] = '{"wpath": []}';
$ Poststr ['hostid: '] = $ uid;
$ Poststr ['privacyparams'] = '{"sourceControl": 99 }';
$ Poststr ['requesttoken'] = $ token;
$ Poststr ['_ mns'] = $ mns;
$ Poststr ['channel'] = "renren ";

$ Head = array (
'Referer: http://shell.renren.com/ajaxproxy.htm ',
'X-Requested-With: XMLHttpRequest ',
);
$ Ch = curl_init ("http://shell.renren.com/?#uid=/status ");
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 "released successfully! ";
} Else {
Echo "shit !!! ";
}

Finally, the release was successful. Of course, you should write one in front of the database. A very simple record library is also the information you want to publish.

From: http://www.mapenggang.com

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.