[英]Auto-fill Form Login Credentials
我要点击的链接是自动登录到第三方网站的结果。 由于我们无法直接控制登录网站的代码,因此更具挑战性。 我认为我们可能暂时必须放弃,直到我们可以让客户的程序员添加JavaScript来解析URL。 然后,我们可以使用用户名和密码进行解析的URL链接。 我已经看过许多解决方案,但是其中每个解决方案都需要页面上包含该表单(我们无权访问)的代码才能正常工作。
最终,我计划创建一个供我们使用的自包含程序,但是到目前为止,我所知道的只是HTML,大量的javascript并且只是从PHP开始。 目前,我们仅使用Cookie在浏览器中存储的已保存登录凭据。 很好,但是我想简化流程,因为我们有太多的客户端登录。 自动登录真是太好了。
我已经看到了一些使用curl来拉出和插入表单字段的东西,但是这超出了我的PHP技能。
谢谢!
曾几何时,我遇到过同样的问题,有2种解决方法:
Greasemonkey是Mozilla Firefox的扩展程序,它允许用户安装脚本,以便在网页加载到浏览器中之后(即也称为增强浏览)进行即时更改。 每次查看网页时都会执行对网页所做的更改,从而使这些更改实际上对于运行脚本的用户而言是永久的。
可从以下网址获得: https : //addons.mozilla.org/en-US/firefox/addon/greasemonkey/
据我称,更好的解决方案是使用firebug的“ net”选项卡来捕获您在填写表单时发送的帖子,并使用Curl重复该帖子。
function post($url,$data) {
$process = curl_init($url);
curl_setopt($process, CURLOPT_HTTPHEADER, $this->headers);
curl_setopt($process, CURLOPT_HEADER, 1);
curl_setopt($process, CURLOPT_USERAGENT, $this->user_agent);
if ($this->cookies == TRUE) curl_setopt($process, CURLOPT_COOKIEFILE, $this->cookie_file);
if ($this->cookies == TRUE) curl_setopt($process, CURLOPT_COOKIEJAR, $this->cookie_file);
curl_setopt($process, CURLOPT_ENCODING , $this->compression);
curl_setopt($process, CURLOPT_TIMEOUT, 30);
if ($this->proxy) curl_setopt($process, CURLOPT_PROXY, $this->proxy);
curl_setopt($process, CURLOPT_POSTFIELDS, $data);
curl_setopt($process, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($process, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($process, CURLOPT_POST, 1); w
$return = curl_exec($process);
curl_close($process);
return $return;
}
资料来源:
1) https://addons.mozilla.org/zh-CN/firefox/addon/greasemonkey/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.