我需要登錄PHP腳本,使用CURL到Joomla網站,才能訪問需要處理的私人頁面,但是儘管我已經做了幾次嘗試,總是有403錯誤。我做了與其他網站類似的事情,它的工作。通過腳本CURL登錄到Joomla網站
腳本我用:
$uname = "id";
$upswd = "pswd";
$url = "http://www.somewebpage.com";
$agent = "'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.6) Gecko/20060728 Firefox/1.5.0.6'";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_COOKIEJAR, './cookie.txt');
curl_setopt($ch, CURLOPT_COOKIEFILE, './cookie.txt');
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
curl_setopt($ch, CURLOPT_HEADER, TRUE);
curl_setopt($ch, CURLOPT_REFERER, $url1);
// POST fields
$postfields = array();
$postfields['username'] = urlencode($uname);
$postfields['passwd'] = urlencode($upswd);
$postfields['remember'] = 'yes';
$postfields['option'] = 'login';
$postfields['op2'] = 'login';
$postfields['return'] = urlencode($url);
$postfields['message'] = '0';
$postfields['force_session'] = '1';
$postfields['j3b00d36f4336137f4f03335c5eee6440'] = '1';
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields);
$ret = curl_exec($ch);
的用戶名和密碼,以及我使用的是完全工作的網站URL。
這是結果我得到:
HTTP/1.1 100 Continue
HTTP/1.1 403 Forbidden
Date: Sat, 06 Feb 2010 08:29:36 GMT
Server: Apache/2.2.13 (Unix) mod_ssl/2.2.13 OpenSSL/0.9.7a DAV/2 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635
X-Powered-By: PHP/5.2.10
Connection: close
Transfer-Encoding: chunked
Content-Type: text/html
有什麼錯誤的,我捲曲的要求?或者Joomla遠程登錄有限制嗎?
感謝您的建議!
我也在想這個。順便說一句,它也失敗了命令行CURL ... – Paryeshakaya 2010-02-06 08:59:15
據我所知,你沒有訪問服務器的日誌,看看它產生了什麼錯誤? – 2010-02-06 09:52:02
不幸的是:-( – Paryeshakaya 2010-02-06 11:02:21