Hi,
I login to the Facebook site, how can I get the UID? Uisng http://mechanize.rubyforge.org/mechanize/
Hi,
I login to the Facebook site, how can I get the UID? Uisng http://mechanize.rubyforge.org/mechanize/
I have no experience with Mechanize (or Ruby), but that looks like a web crawler.
Easiest place to pickup the user id from the current Facebook home page, the profile link.
It takes the form http://www.facebook.com/profile.php?id=UID&ref=profile. UID is a 64-bit integer. Note that Facebook likes to do a lot of client side processing, so you're best just searching for "profile?id=".
You could just use something like http://rfacebook.rubyforge.org/ and write an actual Facebook application. This gives you well-defined API calls for getting things like someone's UID without needing to worry about screen-scraping.
I've just spent some time writing a Facebook app in Python and the API is reasonably easy to work with.
That said, if you're set on screen scraping, it looks like the UID is embedded multiple times throughout the source of, e.g., the home page. Have you tried "view source"? The following form appears to be embedded in most pages, and contains the UID clearly labelled as an elemet inside an HTML :
<div id="autoset_timezone" style="display: none">
<form method="get" action="/ajax/autoset_timezone_ajax.php" name="tz_autoset_form" id="tz_autoset_form">
<input type="hidden" id="post_form_id" name="post_form_id" value="9d6bfda325b20b769431ea6f023ac9ee" autocomplete="off" />
<input type="hidden" id="user" name="user" value="26992" autocomplete="off" />
<input type="hidden" id="tz_gmt_off" name="tz_gmt_off" value="-300" autocomplete="off" />
<input type="hidden" id="time" name="time" value="1264648516" autocomplete="off" />
</form>