2013-03-26 94 views
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; 
} 

?> 

任何想法?现在在网上搜索了几个小时,并且还没有找到解决方案。
谢谢!

+0

什么隐藏的输入字段?确保除了用户名和密码之外还通过了这些 – luk3thomas 2013-03-26 12:45:28

+0

感谢您的提示,我检查了网站并没有发现任何其他输入字段。使用我唯一的凭证名称和密码正常登录页面。 – 2013-03-26 12:48:33

+0

您是否验证过实际上有值写入cookiejar?而且权限是正确的...? – 2013-03-26 16:18:49

回答

0

我没有找到任何解决方案。不过,我手动完成了所有的工作,不再需要程序了,无论如何感谢评论:)