我从窗户里探头往外看,嘿!春天果然到来了。看,外面嫩绿的小草像动画片里的那样,慢慢探出头来。再看,那平坦的草地里,星星点点的眨着眼睛的是什么?哦!那是可爱的小花,还有小虫在花瓣里钻来钻去呢?嘻,原来是童话故事里睡在花瓣里的拇指姑娘啊!再看看,那干枯已久的柳树也伸出了嫩绿的手,轻轻地走来了美丽的春姑娘!
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模拟登录人人(校内)网的简单实例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持。