<?php
date_default_timezone_set('PRC');
$ch = curl_init();
$postFields = 'email=邮箱&password=密码&remember=1';
$httpHeader = [
'Content-Type: application/x-www-form-urlencoded; charset=utf-8',
'Content-Length: ' . strlen($postFields),
];
curl_setopt($ch, CURLOPT_URL, 'http://www.imooc.com/account/login');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postFields);
curl_setopt($ch, CURLOPT_HTTPHEADER, $httpHeader);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
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_exec($ch);
$httpHeader = [
'Content-Type: text/xml',
];
curl_setopt($ch, CURLOPT_URL, 'http://www.imooc.com/u/3073012');
curl_setopt($ch, CURL_POST, false);
curl_setopt($ch, CURL_HTTPHEADER, $httpHeader);
$result = curl_exec($ch);
curl_close($ch);
echo $result;