.

Monday, June 28, 2010

By using Facebook instead of a web form, a new user can provide all of the information required for site registration with a single dialog (no typing required!)

The Graph API can provide access to all of the basic account registration data you would typically request in a sign-up form for your site, including name, email address, profile picture, and birthday. By using Facebook instead of a web form, a new user can provide all of the information required for site registration with a single dialog (no typing required!). Likewise, the information is more reliable than the information you would get in a web form. For example, the email address provided via Facebook has been verified by Facebook, so it does not need to be re-verified by your site.
Some of the basic account registration data you might want to collect in your registration process is private, so it requires requesting extended permissions from the user in the login process. Check out the authentication guide for more details about extended permissions. To request the user's email address and birthday in the login process, use the perms argument to the fb:login-button tag to request the required permissions:

This login button will produce an authorization dialog that looks like this:
Authentication dialog

Once the user authorizes your site, you can fetch those fields from the user's profile:








$user = json_decode(file_get_contents(
    'https://graph.facebook.com/me?wrap_access_token=' .
    $cookie['oauth_access_token']))->me;
register_user($user->id, $user->email, $user->name, $user->username,
              $user->birthday_date);

A user's profile picture can always be accessed at the same URL:
http://graph.facebook.com/UID/picture

For example, Mark Zuckerberg's profile picture is http://graph.facebook.com/4/picture. The URL will always refer to the most recent profile picture, which ensures that if a user updates his or her picture on Facebook, those changes will be reflected on your site.

0 comments:

Post a Comment

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | Macys Printable Coupons