I would like to make a script that will go to a website like "http://www.facebook.com" and login to the website, automatically. Perhaps it would be even better if the user could see the script log the user in, with an iFrame. I also need the script to load the account from a .txt file that will fetch the username separated by "username:password".

How could I do this?

Thank you.

4 Years
Discussion Span
Last Post by Banderson

It depends on remote websites, something like facebook allows remote logins only with OAuth methods, this means a user of facebook doesn't need to share his own credentials (as the password) with your service, check this for more information: https://developers.facebook.com/docs/facebook-login/

In other cases (HTTP Basic Authentication & Co.) you can just send something like this username:password@website.tld to the correct resource and gain access.

Or you have to send a POST request with appropriate values to the script that usually receives the data of the login form.

In most cases you will use the cURL library, so if you want to try check the documentation: http://php.net/manual/en/book.curl.php

If you still have doubts post your code, we will try to help.


Wow, thanks for the quick response Cerial!

Could you give me an example of a script that gets username:password from a .txt file and then logs in to FaceBook?


What are you asking. whatever.txt(has username+password)
==php script calls whatever.txt==
is this username and password on the same line? Are there other lines in this whatever.txt or is it just one line?
==php script fetches the username and password then enters the username to fb login page?==
--> provide more details. or are you just trying to hack fb account.


First off let's get something straight: I'm not hacking anything.

The accounts will be loaded onto a .txt file something like this:


This file will be uploaded to a directory in my web server.

Then the PHP script will enter those details from the top down and enter them in the fields. It will then click login.


PHP can read text files with any separator you input.
The text files needs to be read access on your server to be read.
However, you do know this will expose your passwords and acccount information to anyone that finds the path to this text file on your server, right?

In other words, I highly recommend you do not store sensitive information in a text file.
As cereal said, use Facebook's API. It has been tested for security and you will be within the boundries of the developer's agreement.

Edited by Banderson

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.