Created
July 12, 2012 10:13
-
-
Save diorahman/3097187 to your computer and use it in GitHub Desktop.
facebook login
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var page = require('webpage').create() | |
page.settings.userAgent = 'Mozilla/5.0 (X11; Linux i686; rv:10.0) Gecko/20100101 Firefox/10.0'; | |
var address = 'https://www.facebook.com/dialog/oauth?client_id=399722263402550&redirect_uri=https://www.facebook.com/connect/login_success.html&type=user_agent&display=touch&scope=email' | |
page.open(address, function(status){ | |
if(status == 'success'){ | |
var res = page.evaluate(function(){ function login(username, password){ if('continue' == 'break') return JSON.stringify(obj); document.querySelector('input[name=email]').value=username; document.querySelector('input[name=pass]').value=password; document.querySelector('input[name=login]').click();}; var obj = {'message':'success','stage':'aegislabs_facebook_login_page'}; var location = window.location.toString(); obj.location = location; var title = document.title; obj.title = title; var errorDiv = document.querySelector('div.abb.acr.aps');var mailField = document.querySelector('input[name=email]'); var passField = document.querySelector('input[name=pass]'); if(errorDiv){obj.message='facebook_login_error';} else if(mailField || passField){obj.debug=login('[email protected]','dio10201');} else if(document.querySelector('input[name=grant_clicked]')){document.querySelector('input[name=grant_clicked]').click();}else if(window.location.toString().indexOf('#access_token') > -1){ obj.stage='aegislabs_facebook_access_token_page'; var tokenInfo = window.location.toString().split('#')[1]; var tokenInfoArr = tokenInfo.split('&'); for(var l = 0; l < tokenInfoArr.length; l++){var kv=tokenInfoArr[l].split('='); obj[kv[0]]=kv[1];}}obj.service = 'facebook'; obj.dummy = 'continue'; return JSON.stringify(obj);}) | |
var msg = JSON.parse(res) | |
if(stage == 'aegislabs_facebook_access_token_page') | |
page.exit() | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment