第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定

自定義跳轉(zhuǎn)實(shí)現(xiàn)問題

//自定義跳轉(zhuǎn)方式
$loginurl?=?'http://idcbgp.cn/user/login';
$spaceurl?=?'http://idcbgp.cn/space/index';
$param?=?'username=yourusername&password=yourpass&remember=1';
$ch?=?curl_init();
curl_setopt($ch,?CURLOPT_URL,?$loginurl);
curl_setopt($ch,?CURLOPT_RETURNTRANSFER,?1);

//Cookie相關(guān)設(shè)置,這部分設(shè)置需要在所有會話開始之前設(shè)置
//使用Cookie時,必須先設(shè)置時區(qū)
date_default_timezone_set('PRC');
curl_setopt($ch,?CURLOPT_COOKIESESSION,?1);
//?注釋掉這行,因?yàn)檫@個設(shè)置必須關(guān)閉安全模式?以及關(guān)閉open_basedir,對服務(wù)器安全不利
//curl_setopt($curlobj,?CURLOPT_FOLLOWLOCATION,?1);
curl_setopt($ch,?CURLOPT_HEADER,?0);
curl_setopt($ch,?CURLOPT_POST,?1);
curl_setopt($ch,?CURLOPT_POSTFIELDS,?$param);
curl_setopt($ch,?CURLOPT_HTTPHEADER,?array('applicaiton/x-www-form-urlencoded;?charset=utf-8',
????'Content-length:?'.strlen($param)
????));
curl_exec($ch);
//進(jìn)入空間
curl_setopt($ch,?CURLOPT_URL,?$spaceurl);
curl_setopt($ch,?CURLOPT_POST,?0);
curl_setopt($ch,?CURLOPT_HTTPHEADER,?array("Content-type:?text/xml"));
$output?=?curl_redir_exec($ch);?//執(zhí)行
curl_close($ch);
echo?$output;



//自定義實(shí)現(xiàn)頁面鏈接跳轉(zhuǎn)抓取
function?curl_redir_exec($ch,?$debug='')?{
????static?$curl_loops?=?0;
????static?$curl_max_loops?=?20;

????if($curl_loops++?>=?$curl_max_loops)?{
????????$curl_loops?=?0;
????????return?false;
????}
????//開啟header才能夠抓取到重定向到新的新URL
????curl_setopt($ch,?CURLOPT_HEADER,?true);
????curl_setopt($ch,?CURLOPT_RETURNTRANSFER,?true);
????$data?=?curl_exec($ch);
???
????//分割返回的內(nèi)容?
????$h_len?=?curl_getinfo($ch,?CURLINFO_HEADER_SIZE);
????$header?=?substr($data,?0,?$h_len);
????$data?=?substr($data,?$h_len-1);
???
????
????$http_code?=?curl_getinfo($ch,?CURLINFO_HTTP_CODE);
????//echo?$http_code."<br?/>";
????if($http_code?==?301?||?$http_code?==?302)?{
????????$matches?=?array();
????????preg_match('/Location:(.*?)\n/',?$header,?$matches);
???????
????????$url?=?@parse_url(trim(array_pop($matches)));
????????//print_r($url);die;
????????if(!$url)?{
????????????$curl_loops?=?0;
????????????return?$data;
????????}
????????//最后一個有效的URL地址
????????$last_url?=?parse_url(curl_getinfo($ch,?CURLINFO_EFFECTIVE_URL));
????????if(!isset($url['scheme']))?{
????????????$url['scheme']?=?$last_url['scheme'];
????????}
????????if(!isset($url['host']))?{
????????????$url['host']?=?$last_url['host'];
????????}
????????if(!isset($url['path']))?{
????????????$url['path']?=?$last_url['path'];
????????}
????????$new_url?=?$url['scheme'].'://'.$url['host'].$url['path'].(isset($url['query'])???'?'.$url['query']?:?'');
???????
????????curl_setopt($ch,?CURLOPT_URL,?$new_url);
????????return?curl_redir_exec($ch,$last_url);
????}?else?{
????????$curl_loops?=?0;
????????return?$data;
????}
}

直接輸入正確的用戶名,密碼,在跳轉(zhuǎn)之前輸出能得到登陸成功的信息,但是調(diào)用自定義跳轉(zhuǎn)的方法時,每次都返回到登陸頁面,無法進(jìn)入課程中心,這是老師給提供的代碼,是不是少設(shè)置什么信息了

正在回答

0 回答

舉報

0/150
提交
取消

自定義跳轉(zhuǎn)實(shí)現(xiàn)問題

我要回答 關(guān)注問題
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號