Skip to content

Instantly share code, notes, and snippets.

@hubgit
Created February 17, 2010 14:08
Show Gist options
  • Save hubgit/306638 to your computer and use it in GitHub Desktop.
Save hubgit/306638 to your computer and use it in GitHub Desktop.
Login to Facebook using cURL
#!/bin/bash
# If it redirects to http://www.facebook.com/login.php at the end, wait a few minutes and try again
EMAIL='YOUR_EMAIL' # edit this
PASS='YOUR_PASSWORD' # edit this
COOKIES='cookies.txt'
USER_AGENT='Firefox/3.5'
curl -X GET 'https://www.facebook.com/home.php' --verbose --user-agent $USER_AGENT --cookie $COOKIES --cookie-jar $COOKIES --location # redirects to https://login.facebook.com/login.php
curl -X POST 'https://login.facebook.com/login.php' --verbose --user-agent $USER_AGENT --data-urlencode "email=${EMAIL}" --data-urlencode "pass=${PASS}" --cookie $COOKIES --cookie-jar $COOKIES
curl -X GET 'https://www.facebook.com/home.php' --verbose --user-agent $USER_AGENT --cookie $COOKIES --cookie-jar $COOKIES
@abdul-shajin
Copy link

Can we open facebook as logged-in with this cookies??

@sk8darr
Copy link

sk8darr commented Apr 14, 2015

Good work! How can i do the same for another webpages login?

@codex-corp
Copy link

it's no longer work

@31eet
Copy link

31eet commented Apr 1, 2018

it worked .. but when i tried to register a new account with facebook .. its not working

#!/bin/bash

If it redirects to http://www.facebook.com/login.php at the end, wait a few minutes and try again

echo "no cookies" >> cookies.txt
echo "no content" >> a.html
rm cookies.txt
rm a.html
EMAIL='YOUR_EMAIL' # edit this
PASS='YOUR_PASSWORD' # edit this
echo "enter fn,ln,,em,em"
read firstname
read lastname
read reg
read newp
read passw

COOKIES='cookies.txt'
USER_AGENT='Firefox/3.5'

curl -X GET 'https://www.facebook.com/reg' --verbose --user-agent $USER_AGENT --cookie $COOKIES --cookie-jar $COOKIES --location # redirects to https://login.facebook.com/login.php
curl -X POST 'https://www.facebook.com/r.php' --verbose --user-agent $USER_AGENT --data-urlencode "firstname=${firstname}" --data-urlencode "lastname=${lastname}" --data-urlencode "reg_email__=${reg}" --data-urlencode "reg_email_confirmation__=${reg}" --data-urlencode "birthday_year=1997" --data-urlencode "reg_passwd__=${newp}" --data-urlencode "reg_passwd__=${passw}" --data-urlencode "birthday_day=2" --data-urlencode "sex=2" --data-urlencode "birthday_month=1" --cookie $COOKIES --cookie-jar $COOKIES >> b.html
curl -X GET 'https://www.facebook.com/reg' --user-agent $USER_AGENT --cookie $COOKIES --cookie-jar $COOKIES >> a.html

@jenoleno
Copy link

@31eet, how did you manage to login successfully? I tried this recently and it does not work. I am redirected to the login page

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment