Created
September 11, 2012 09:48
-
-
Save ariefbayu/3697293 to your computer and use it in GitHub Desktop.
facebook status update using phantomjs
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 = new WebPage(); | |
//spoof it as opera mini, to get the mobile page working properly | |
page.settings.userAgent = "Opera/9.80 (J2ME/MIDP; Opera Mini/6.5.26955/27.1407; U; en) Presto/2.8.119 Version/11.10"; | |
function doLogin(){ | |
page.evaluate(function(){ | |
var frm = document.getElementById("login_form"); | |
frm.elements["email"].value = "--enter-your-email--"; | |
frm.elements["pass"].value = "--enter-your-password--"; | |
frm.submit(); | |
}); | |
} | |
function doUpdateStatus(){ | |
page.evaluate(function(){ | |
var form = document.getElementById("composer_form"); | |
form.elements["status"].value = "--write-down-your-status-message--"; | |
form.submit(); | |
}); | |
} | |
page.onLoadFinished = function(status){ | |
console.log( (!phantom.state ? "no-state" : phantom.state) + ": " + status ); | |
if(status === "success"){ | |
if( !phantom.state ){ | |
doLogin(); | |
phantom.state = "logged-in"; | |
} else if(phantom.state === "logged-in"){ | |
doUpdateStatus(); | |
phantom.state = "status-updated"; | |
} else if(phantom.state === "status-updated"){ | |
phantom.exit(); | |
} | |
} | |
}; | |
page.onConsoleMessage = function (message){ | |
console.log("msg: " + message); | |
}; | |
page.open("http://m.facebook.com"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here is a good post explaining how to login to the Facebook using CasperJS and get all images greater than 100x100 pixels from the timeline: http://code-epicenter.com/how-to-login-to-facebook-using-casperjs/