lu在脚下
2015-10-30 01: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;
?>
http://blog.csdn.net/whq19890827/article/details/46654501你看下这里面的吧,不知道对你有帮助没!
或者同伴们贴一下代码
PHP中的数据传输神器cURL
34279 学习 · 218 问题
相似问题