PHP Use Curl Analog login for Everyone (campus) network Simple example _php instance

Source: Internet
Author: User
Tags curl

PHP uses curl to simulate a simple instance of everyone (on-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); 
With cookies file, access to Renren home $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 the content of the home page of Renren Print_r ($contents); 

Above this PHP use Curl Analog login Everyone (Campus) network Simple example is small series to share all the content, hope to give you a reference, also hope that we support cloud habitat community.

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.