∮Ω奧米加空間∮»PHP 交流區»【原創】自動登入 Authorization 的網頁
| 作者 |
主題 |
dc
管理員

性別:男
來自:瓦肯星
發表總數:11621
註冊時間:2002-05-07 16:32 |
(第 1 篇) 【原創】自動登入 Authorization 的網頁
參考了網頁很多資料才試出來
例如有個網站是 192.168.1.10
我們要讀取其中一個檔案 路徑是 http://192.168.1.10/test/test.txt
Authorization 有設定帳密 帳號 123 密碼 45@78
| 代碼: |
$fp = fsockopen("192.168.1.10",80);
fputs($fp,"GET /test/test.txt HTTP/1.1\r\n");
fputs($fp, "Content-Type: text/xml\r\n");
fputs($fp,"Host: 192.168.1.10\r\n");
fputs($fp,"Authorization: Basic " . base64_encode("123:45@78") . "");
fputs($fp,"Connection: Close\r\n\r\n");
//在螢幕前列印出來
fpassthru($fp);
|
要存成檔案的話將
fpassthru($fp);
改成
file_put_contents( 'test.txt', $fp);
本帖由dc最後編輯於2013-11-06 14:04
Your mind to my mind,
your thought to my thought |
| 發表時間:2013-11-06 14:03 |
|
|
所有時間均為GMT+8, 現在是2026-02-11 01:18 |
|