php 使用curl模拟登录人人(校内)网的简单实例
程序员文章站
2024-04-02 14:00:22
php 使用curl模拟登录人人(校内)网的简单实例
$login_url = 'http://passport.renren.com/plogin.do';...
php 使用curl模拟登录人人(校内)网的简单实例
$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);
以上这篇php 使用curl模拟登录人人(校内)网的简单实例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持。
上一篇: php中mkdir()函数的权限问题分析