Php curl simulates login to Renren's published status

Source: Internet
Author: User
Tags curl

The code is as follows: Copy code

<? Php
$ Cookie_file = dirname (_ FILE _). "/renren. cookie ";

$ Login_url = 'http: // passport.renren.com/plogin.do ';

$ Post_fields ['email '] = ''; // your account
$ Post_fields ['password'] = ''; // password for everyone
$ 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 );
Curl_close ($ ch );
// 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 );
// Obtain the user ID
$ Tmp = explode ('/', $ info ['redirect _ url']);
$ Uid = array_pop ($ tmp );
Unset ($ tmp );

// $ Uid = "305115027 ";
// Obtain the token and mnsx.

$ Send_url = 'http: // www.renren.com/'.w.uid;
$ 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 );
$ Token = $ arr [1] [0]; // 1121558104
$ Scn = $ arr [2] [0]; // e9a9cb2

// Publish information
$ Poststr ['content'] = "this is just a test !!! ";
$ 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 );
$ Data = json_decode ($ content, true );
If ($ data ["code"] = "0 "){
Echo "released successfully! ";
} Else {
Echo "shit !!! ";
}

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.