0
here's我的問題:
捲曲登錄
我正嘗試讓一個網站,首先需要登錄的內容。我想通過cURL解決這個問題。 首先,我連接到登錄頁面,而不是連接到需要登錄的頁面。 我在我的cookie文件中得到了一些Cookies,但是當我嘗試查看需要登錄的頁面的內容之前,我只能將其重定向到(獲取內容)登錄頁面。
看來,我的解析登錄cookie或什麼失敗,所以網站鴕鳥政策remeber我登錄
繼承人是我的PHP代碼至今:
<?php
$loginUrl = 'https://www.****./login.html';
$loginFields = array('j_username'=>'***', 'j_password'=>'**'); //login form field names and values
$remotePageUrl = 'https://www.***/myPage/index.html'; //url of the page I want the content
$login = getUrl($loginUrl, 'post', $loginFields); //login to the site
echo $remotePage = getUrl($remotePageUrl); //get the remote page
function getUrl($url, $method='', $vars='') {
$ch = curl_init();
if ($method == 'post') {
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $vars);
}
curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_COOKIESESSION, 1);
curl_setopt($ch, CURLOPT_COOKIEJAR, 'C:\\xampp\htdocs\***\cookies.txt');
curl_setopt($ch, CURLOPT_COOKIEFILE, 'C:\\xampp\htdocs\****\cookies.txt');
$buffer = curl_exec($ch);
if (curl_error($ch)) echo curl_error($ch);
curl_close($ch);
return $buffer;
}
?>
任何想法?現在在網上搜索了幾個小時,並且還沒有找到解決方案。
謝謝!
什麼隱藏的輸入字段?確保除了用戶名和密碼之外還通過了這些 – luk3thomas 2013-03-26 12:45:28
感謝您的提示,我檢查了網站並沒有發現任何其他輸入字段。使用我唯一的憑證名稱和密碼正常登錄頁面。 – 2013-03-26 12:48:33
您是否驗證過實際上有值寫入cookiejar?而且權限是正確的...? – 2013-03-26 16:18:49