This article mainly introduces PHP using curl to achieve the simulation of the method of the campus Renren, interested in the friend's reference, I hope to help you.
PHP uses curl to simulate a simple example of logging in to everyone (campus) network
$login _url = ' http://passport.renren.com/PLogin.do '; $post _fields[' email '] = ' XXXX '; $post _fields[' password '] = ' XXXX '; $post _fields[' origurl '] = ' http%3a%2f%2fhome.renren.com%2fhome.do '; $post _fields[' domain '] = ' renren.com '; The cookie file is stored under the Temp folder in the root directory of the Web site $cookie _file = Tempnam ('./temp ', ' Cookie '); $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); Curl_exec ($ch); Curl_close ($ch); Bring a cookie file, visit Renren homepage $send _url= ' http://home.renren.com/Home.do '; $ch = Curl_init ($send _url); curl_setopt ($ch, Curlopt_header, 0); curl_setopt ($ch, Curlopt_returnTRANSFER, 1); curl_setopt ($ch, Curlopt_cookiefile, $cookie _file); $contents = curl_exec ($ch); Curl_close ($ch); Clean cookie file unlink ($cookie _file); Output Renren Home page content Print_r ($contents);
Summary: The above is the entire content of this article, I hope to be able to help you learn.