简体   繁体   中英

Auto-fill Form Login Credentials

What I'd like is to hit my link with the result of an auto login to a 3rd party site. Because we don't have direct control of the login site's code, it makes it more challenging. I'm thinking we may just have to give up for now until we can get our clients' programmers to add javascript to parse URLs. Then we can just do a parsed URL link with the username and password. I've looked through tons of solutions already, but every single one of them requires code on the page holding the form (which we don't have access to) for it to work.

Eventually I plan to create a self contained program for us to use, but for now all I know is HTML, a good amount of javascript and just starting on PHP. Currently we're just using the saved login creds stored by cookies in the browsers. This is fine, but I want to stream line the process since we have way too many client logins. It would be so nice to have auto-login.

I had seen something using curl to pull and insert form fields, but that's beyond my PHP skills at the moment.

Thanks!

I had the same issues once upon a time , there are 2 ways out:

Greasemonkey:

Greasemonkey is a Mozilla Firefox extension that allows users to install scripts that make on-the-fly changes to web page content after or before the page is loaded in the browser (also known as augmented browsing). The changes made to the web pages are executed every time the page is viewed, making them effectively permanent for the user running the script.

It is available at: https://addons.mozilla.org/en-US/firefox/addon/greasemonkey/

Using firebug

According to me the better solution is to use the firebug 'net' tab to capture the post sent when you fill up the form and repeat that post with 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; 
} 

Sources:

1) https://addons.mozilla.org/en-US/firefox/addon/greasemonkey/

2) Auto fill and submit forms on external site

3) http://en.wikipedia.org/wiki/Greasemonkey

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM