<?php
$data='email=xxx&pwd=xxxx&verifyCode=&save_login=0';
$login_url='https://www.oschina.net/action/user/hash_login';
$url='https://my.oschina.net/simaguo/admin/profile';
$hd = curl_init();
curl_setopt($hd,CURLOPT_URL,$login_url);
curl_setopt($hd,CURLOPT_RETURNTRANSFER,true);
curl_setopt($hd,CURLOPT_TIMEOUT,10);
date_default_timezone_set('PRC');
curl_setopt($hd,CURLOPT_COOKIESESSION,true);
curl_setopt($hd,CURLOPT_COOKIEFILE,'cookiefile');
curl_setopt($hd,CURLOPT_COOKIEJAR,'cookiefile');
curl_setopt($hd,CURLOPT_COOKIE,session_name().'='.session_id());
curl_setopt($hd,CURLOPT_HEADER,0);
curl_setopt($hd,CURLOPT_FOLLOWLOCATION,1);
curl_setopt($hd,CURLOPT_POST,1);
curl_setopt($hd,CURLOPT_POSTFIELDS,$data);
curl_setopt($hd,CURLOPT_HTTPHEADER,array("application/x-www-form-urlencoded;charset=utf-8","Content-length:".strlen($data)));
curl_exec($hd);
curl_setopt($hd,CURLOPT_URL,$url);
curl_setopt($hd,CURLOPT_POST,0);
curl_setopt($hd,CURLOPT_HTTPHEADER,array("ontent-type:text/html; charset=UTF-8"));
$output = curl_exec($hd);
curl_close($hd);
echo str_replace('href="/','href="https://www.oschina.net/',str_replace('src="/','src="https://www.oschina.net/',$output));
注:pwd是加密后的密码