我想通过 phpcurl 自动登录我的 Horde Webmail,然后显示我所有的电子邮件。到目前为止,我的登录工作完美。我使用凭据和 Cookie 登录。
有什么问题?
我的仪表板显示但没有任何数据。这是一个屏幕截图:

我会得到什么错误输出?
在控制台中它说:
Failed to load resource: the server responded with a status of 404 (Not Found)
这是我的控制台的屏幕截图:

到目前为止我使用什么代码?
//Data
$webmail_login = "http://webmail.licht-austria.at/login.php";
$webmail_mailbox = "http://webmail.licht-austria.at/imp/dynamic.php?page=mailbox";
$login = "";
$password = '';
$postdata = "login_post=1&horde_user=$login&horde_pass=$password&horde_select_view=auto&new_lang=de_DE";
//Curl Login POST
$ch = curl_init();
$agent = $_SERVER["HTTP_USER_AGENT"];
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
curl_setopt($ch, CURLOPT_URL, $webmail_login );
curl_setopt($ch, CURLOPT_NOBODY, 1);
curl_setopt($ch, CURLOPT_POST, 1 );
curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookie.txt');
$result = curl_exec($ch);
//Until here it works i logged in
//Curl Mailbox GET
curl_setopt($ch, CURLOPT_URL, $webmail_mailbox);
curl_setopt($ch, CURLOPT_POST, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLINFO_HEADER_OUT, true);
$data = curl_exec($ch);
echo $data;
我的代码如何运作?
在第一步中,我使用我的凭据并通过 POST 登录到我的 Webmail。PostData 是正确的,我可以登录。webmail.at/login.php 完成后,我会重定向到我的收件箱(webmail.at/imp/dynamic.php?page=mailbox)。网络邮件现在使用 GET 方法获取所有电子邮件和资料,此时我收到 404 错误。