Home > Backend Development > PHP Tutorial > PHP uses curl to simulate a simple example of logging into Renren (school) network, curl school_PHP tutorial

PHP uses curl to simulate a simple example of logging into Renren (school) network, curl school_PHP tutorial

WBOY
Release: 2016-07-12 08:49:59
Original
763 people have browsed it

php A simple example of using curl to simulate logging into Renren (school) network, curl school

php using curl to simulate logging into Renren (school) network Simple example

$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'; 
//cookie文件存放在网站根目录的temp文件夹下 
$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); 
 
//带上cookie文件,访问人人网首页 
$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); 
 
//清理cookie文件 
unlink($cookie_file); 
 
//输出人人网首页的内容 
print_r($contents);
Copy after login

The above simple example of php using curl to simulate logging into Renren (school) network is all the content shared by the editor. I hope it can give you a reference, and I also hope that everyone will support Bangkejia.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1135018.htmlTechArticlephp uses curl to simulate a simple example of logging into Renren (school) network, curl campus php uses curl to simulate logging into Renren Simple example of (on-campus) network $login_url = 'http://passport.renren.com/PLogin.d...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template