curl无法登陆慕课
为什么我的也不行啊,求 分享个连接成功的,或者老师,重新上传一份文件
为什么我的也不行啊,求 分享个连接成功的,或者老师,重新上传一份文件
2015-10-30
<?php
/*
查看慕课网某用户的课程信息
*/
$data = 'email= &password=&remember=1';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://www.imooc.com");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); //保存结果 不输出
date_default_timezone_set('PRC'); //设置时区
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); //不使用认证
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE); //不使用认证
curl_setopt($ch, CURLOPT_COOKIESESSION, true);
curl_setopt($ch, CURLOPT_COOKIEFILE, "cookiefile");
curl_setopt($ch, CURLOPT_COOKIEJAR, "cookiefile");
curl_setopt($ch, CURLOPT_COOKIE, session_name(). '=' . session_id());
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); //支持页面跳转
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("application/x-www-form-urlencoded;charset=utf-8","Content-Length: " . strlen($data)));
curl_exec($ch);
curl_setopt($ch, CURLOPT_URL, "http://www.imooc.com/u/2985311/courses");
curl_setopt($ch, CURLOPT_POST, 0);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-type: text/xml"));
$output = curl_exec($ch);
curl_close($ch);
echo $output;
?>
举报