【发布时间】:2017-06-10 11:05:42
【问题描述】:
这个问题类似于this older question。
那里的解决方案似乎对我有用,但我得到的结果是未登录。我在第二个请求中得到了页面,但不是作为用户。 我应该改变什么? 代码如下:
<?php
$urlini='https://www.example.com/login';
$url='https://www.example.com/page-12345';
$ch = curl_init();
$fp = fopen(dirname(__FILE__).'/errorlog.txt', 'w');
curl_setopt($ch, CURLOPT_POST,true);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_STDERR, $fp);
curl_setopt($ch, CURLOPT_URL, $urlini);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_CAINFO, getcwd() . "/certificate.pem");
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query(array('email' => 'email@example.com' , 'password' => 'password')));
curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$store = curl_exec($ch);
curl_setopt($ch, CURLOPT_URL, $url);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
?>
当我没有回显$response,回显$store 时,我看到表单中填写了用户名,但没有填写密码。网站上登录表单的代码是:
<div class="form_wrapper"><div class="form" id="login_form">
<span class="form_title hidden-xs">Log in</span><input id="email" name="id" type="email" placeholder="Email address" class="validate[required,custom[email]]"/>
<input id="password" name="password" type="password" placeholder="Password" class="validate[required,minSize[5],custom[passwordLegalChars]]"/><a
id="login_button" class="css_button css_button_big css_button_default" role="button" tabindex="0" >Log in</a>
【问题讨论】:
-
@bub:我说问题很相似,我在那里尝试了解决方案,但它并没有为我解决问题。这里的问题与其他问题不重复,因为其他问题的答案是我的出发点。
-
也许您缺少一些用于登录的帖子字段,或者另一个常见问题是缺少发送用户代理字符串。很难说没有看到输出,登录页面的来源知道是否缺少任何东西。