欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

php怎么通過(guò)curl模擬登陸DZ論壇-創(chuàng)新互聯(lián)

本篇內(nèi)容主要講解“php怎么通過(guò)curl模擬登陸DZ論壇”,感興趣的朋友不妨來(lái)看看。本文介紹的方法操作簡(jiǎn)單快捷,實(shí)用性強(qiáng)。下面就讓小編來(lái)帶大家學(xué)習(xí)“php怎么通過(guò)curl模擬登陸DZ論壇”吧!

創(chuàng)新互聯(lián)公司專注為客戶提供全方位的互聯(lián)網(wǎng)綜合服務(wù),包含不限于成都網(wǎng)站制作、成都網(wǎng)站建設(shè)、武宣網(wǎng)絡(luò)推廣、微信小程序定制開(kāi)發(fā)、武宣網(wǎng)絡(luò)營(yíng)銷、武宣企業(yè)策劃、武宣品牌公關(guān)、搜索引擎seo、人物專訪、企業(yè)宣傳片、企業(yè)代運(yùn)營(yíng)等,從售前售中售后,我們都將竭誠(chéng)為您服務(wù),您的肯定,是我們大的嘉獎(jiǎng);創(chuàng)新互聯(lián)公司為所有大學(xué)生創(chuàng)業(yè)者提供武宣建站搭建服務(wù),24小時(shí)服務(wù)熱線:18980820575,官方網(wǎng)址:chinadenli.net

libcurl同時(shí)也支持HTTPS認(rèn)證、HTTP POST、HTTP PUT、 FTP 上傳(這個(gè)也能通過(guò)PHP的FTP擴(kuò)展完成)、HTTP 基于表單的上傳、代理、cookies和用戶名+密碼的認(rèn)證。

<?php 
$discuz_url = '/tupian/20230522/&
$login_url = $discuz_url .'login.php?action=login';//登錄頁(yè)地址 
 
$post_fields = array(); 
//以下兩項(xiàng)不需要修改 
$post_fields['loginfield'] = 'username'; 
$post_fields['loginsubmit'] = 'true'; 
//用戶名和密碼,必須填寫 
$post_fields['username'] = 'tianxin'; 
$post_fields['password'] = '111111'; 
//安全提問(wèn) 
$post_fields['questionid'] = 0; 
$post_fields['answer'] = ''; 
//@todo驗(yàn)證碼 
$post_fields['seccodeverify'] = ''; 
//獲取表單FORMHASH 
$ch = curl_init($login_url); 
curl_setopt($ch, CURLOPT_HEADER, 0); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
$contents = curl_exec($ch); 
curl_close($ch); 
preg_match('/<input\s*type="hidden"\s*name="formhash"\s*value="(.*?)"\s*\/>/i', $contents, $matches); 
if(!empty($matches)) { 
$formhash = $matches[1]; 
} else { 
die('Not found the forumhash.'); 
} 
 
//POST數(shù)據(jù),獲取COOKIE,cookie文件放在網(wǎng)站的temp目錄下 
$cookie_file = tempnam('./temp','cookie'); 
$ch = curl_init($login_url); 
curl_setopt($ch, CURLOPT_HEADER, 0); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
curl_setopt($ch, CURLOPT_POST, 1); 
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_fields); 
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file); 
curl_exec($ch); 
curl_close($ch); 
//取到了關(guān)鍵的cookie文件就可以帶著cookie文件去模擬發(fā)帖,fid為論壇的欄目ID 
$send_url = $discuz_url."post.php?action=newthread&fid=2"; 
 
$ch = curl_init($send_url); 
curl_setopt($ch, CURLOPT_HEADER, 0); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file); 
$contents = curl_exec($ch); 
curl_close($ch); 
//這里的hash碼和登陸窗口的hash碼的正則不太一樣,這里的hidden多了一個(gè)id屬性 
preg_match('/<input\s*type="hidden"\s*name="formhash"\s*id="formhash"\s*value="(.*?)"\s*\/>/i', $contents, $matches); 
if(!empty($matches)) { 
$formhash = $matches[1]; 
} else { 
die('Not found the forumhash.'); 
} 
 
$post_data = array(); 
//帖子標(biāo)題 
$post_data['subject'] = 'test2'; 
//帖子內(nèi)容 
$post_data['message'] = 'test2'; 
$post_data['topicsubmit'] = "yes"; 
$post_data['extra'] = ''; 
//帖子標(biāo)簽 
$post_data['tags'] = 'test'; 
//帖子的hash碼,這個(gè)非常關(guān)鍵!假如缺少這個(gè)hash碼,discuz會(huì)警告你來(lái)路的頁(yè)面不正確 
$post_data['formhash']=$formhash; 
 
$ch = curl_init($send_url); 
curl_setopt($ch, CURLOPT_REFERER, $send_url); //偽裝REFERER 
curl_setopt($ch, CURLOPT_HEADER, 0); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 0); 
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file); 
curl_setopt($ch, CURLOPT_POST, 1); 
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data); 
$contents = curl_exec($ch); 
curl_close($ch); 
//清理cookie文件 
unlink($cookie_file); 
?>

到此,相信大家對(duì)“php怎么通過(guò)curl模擬登陸DZ論壇”有了更深的了解,不妨來(lái)實(shí)際操作一番吧!這里是創(chuàng)新互聯(lián)建站,更多相關(guān)內(nèi)容可以進(jìn)入相關(guān)頻道進(jìn)行查詢,關(guān)注我們,繼續(xù)學(xué)習(xí)!

網(wǎng)頁(yè)題目:php怎么通過(guò)curl模擬登陸DZ論壇-創(chuàng)新互聯(lián)
網(wǎng)頁(yè)URL:http://chinadenli.net/article16/deijgg.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供用戶體驗(yàn)、網(wǎng)站策劃、網(wǎng)站改版Google、小程序開(kāi)發(fā)、外貿(mào)建站

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

成都網(wǎng)頁(yè)設(shè)計(jì)公司