Mobile app version of vmapp.org
Login or Join
Cugini213

: How do I automatically log my users into other websites after they have given me their passwords? I have to program an application where the users can connect to other websites. For example,

@Cugini213

Posted in: #Authentication #CrossOrigin #Forms

I have to program an application where the users can connect to other websites. For example, the user clicks on the "Amazon" button and the application opens the Amazon website. It then needs to pre-populate the login and password information for the user. (The user added that info to my data base previously.)

My application is in PHP. I have tried using curl to implement this. I can connect, but the cookie is not then used by the users browser.
My problem is a lot of websites are protected with tokens and their is a wide variety of different URLs

I have also tried another solution: the application would only fill in the user and password and the user click on "validate" or "login". After researching this, I've found that it may be more difficult. I haven't found any explication about how to fill a form in another website. I think browsers can do it, and I've seen applications such as 'Dashlane' that can do it to, so I think it should be possible.

How do I implement this feature?

10.02% popularity Vote Up Vote Down


Login to follow query

More posts by @Cugini213

2 Comments

Sorted by latest first Latest Oldest Best

 

@Alves908

I have maybe a solution. VBScript could fill login, because it can to have action on system.

<script language="VBScript">
document.write "<h1>Et ceci du VBscript</h1>"
Set objIE = CreateObject("InternetExplorer.Application")

objIE.Navigate "about:blank"
objIE.Visible = true
objIE.Navigate "www.google.com"

</script>


But I put this code in a html page and I open this page with IE. So i don't want it create a new IE.application. I want it use the IE opened.

Could you help me again please?

10% popularity Vote Up Vote Down


 

@Angela700

You're on the right track with CURL.

What you need to do is add code that reads the website as if it's a basic HTML file then process the file replacing certain HTML code.

If some websites are basic with little to no javascript and contain a login box, then look for code containing something like:

<input type="text" name="username">


and replace it (using PHP's str_replace) with:

<input type="text" name="username" value="importedusername">


and do the same with the password field:

<input type="password" name="password">


and replace it (using PHP's str_replace) with:

<input type="password" name="password" value="importedpassword">


Here's a script to help you get started provided your PHP config is set to allow URLs in file functions, and that the website codes the username and password like I coded it above:

<?php
$myuser="usernametouse";
$mypass="passwordtouse";
$webpage=file_get_contents("http://example.com/loginpage");
$webpage=str_replace('<input type="password" name="password">','<input type="password" name="password" value="'.$mypass.'">',$webpage);
$webpage=str_replace('<input type="text" name="username">','<input type="text" name="username" value="'.$myuser.'">',$webpage);
echo $webpage;
?>


Because website publishers are free to order the parameters in the HTML tags to their liking, the code I present may need to be modified in order to adapt to each site.

For example, They could use:

<input name="username" type="text">


instead of:

<input type="text" name="username">


and if they do that, my code will then need to be modified.

Also, my code does not add any HTML headers. You should however define some with the header() command for better output speed. and place them before the final echo statement in my code.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme