The facebook user Id will always remain constant. To do something similar to what you want you would probably do this:
Step 1 - Authenticate the User
https://developers.facebook.com/docs/authentication/ - You would probably want to use the server side flow.
Step 2 - Get Permissions
https://developers.facebook.com/docs/reference/api/permissions/ - You will need to have the user_about_me permission to get their UserId. You add this to your authentication link above by adding &scope=user_about_me
e.g. http://www.facebook.com/dialog/oauth?client_id=YOURAPPID&scope=user_about_me&redirect_uri=LINKTOCOMEBACKTO
Please note your redirect_uri must be on the same domain as the settings in your app.
If you wanted to create an enhanced dialog box you can look at this:
https://developers.facebook.com/docs/opengraph/authentication/
Step 3- Getting the userid
If you are doing this inside a Facebook App then look at the userId in the SignedRequest.
Otherwise you use the Graph API. Here a StackOverflow question that shows how: How to get the Facebook user id using the access token