Facebook Pages

From Facebook Developer Wiki

Jump to: navigation, search

On March 11, 2009, we introduced the new design for Facebook Pages. Facebook Pages now are more in line with user profiles. You can find more information about the new design in the Facebook Pages Release Notes.



Facebook Pages expand the social graph by enabling businesses to have a presence on Facebook, giving developers access to more users than ever before. Think of a Facebook Page as something like a Facebook profile, only for entities like a business, a band or artist, or a product or even a brand.

Developers can create all-new business-focused applications, partner with businesses to build applications, or simply make the applications they've already built for users available for Facebook Pages. The same applications can work on both Facebook user profiles and Facebook Pages, meaning that developers don't need to do extra work to support Facebook Pages. Read more about Facebook Ads.

Contents

Application Configuration

  • All applications marked as such in the application configuration can be added by both users and Pages.
  • Application developers indicate what type of entity (user or Page) can add the application to their Facebook accounts.
  • This configuration option shows up on the application configuration page: http://www.facebook.com/developers/editapp.php?edit&app_id=YOUR_APP_ID.
  • The default configuration for applications is to work only on user profiles. Developers must change this setting to indicate that their applications are ready to support Pages.
  • You must edit your application settings twice. The first time to check the button to allow Pages to add the application. Then save, then edit settings again to enter the edit page URL.

Adding an Application to a Page

When a Page adds an application, the Page administrator is not automatically logged into the application. The application has permission to access and modify information about the Page without an active session.

When a Page makes a request from or removes an application, Facebook sends an fb_sig_page_id parameter as well as fb_sig_user. The fb_sig_page_id is the ID of the Page that made the request.

You are encouraged not to force the Page admin to log in to the application, as this improves the experience for the admin. For more information, please see Canvas Pages below.

Please note that actions that appear to be taken by a Page are actually taken by one of the Page's admins on behalf of the Page.

Page IDs

All Page IDs are 64 bit IDs. Note that because user IDs were 32 bits (now 64 bits), you may need to update your underlying storage to make sure it can handle 64 bits. --1002392177 05:29, 18 June 2008 (PDT)

Canvas Pages

Canvas pages would work the same way that they do for users right now. Regarding canvas pages for Pages, you are encouraged to pass the fb_page_id query string in all URLs pointing to canvas pages so that we know what Page you are dealing with and can send you some additional information. The following will be sent if the fb_page_id querystring is specified:

  • fb_sig_is_admin - is the logged-in user an admin of the Page?
  • fb_sig_is_fan - is the logged-in user a fan of the Page?
  • fb_sig_page_added = has the Page added the app?

When Facebook needs to steer a Page admin to the correct canvas page for one of the Pages the admin administers, Facebook will point her to http://apps.facebook.com/YOUR_DIRECTORY_NAME/?fb_page_id=PAGE_ID.

NOTE: This url will provide fb_sig_is_admin, and facebook pages does not provide fb_sig_is_admin if you are accessing it like this http://www.facebook.com/pages/YOUR_DIRECTORY/PAGE_ID?v=APPID&viewas=USERID

Application "Profile" Pages

When working with the profile boxes for Facebook pages, pages are treated like users. Pages have distinct ids and are supplied by the GET param fb_sig_page_id. You can use this id pretty much anywhere you can use a user id - setFBML, <fb:name>, etc. You can link to the page profile with http://www.facebook.com/profile.php?id={entityID}. For example, to publish to the pages profile, instead of calling profile_setFBML(NULL, userid, 'profile', NULL, 'mobile_profile', 'profile_main');, you would call profile_setFBML(NULL, pageid, 'profile', NULL, 'mobile_profile', 'profile_main');. Because of this, in this page, I've referred to the ID of the entity viewing the page (whether it is a page or a user) as the entityID. There is, however, some additional logic required to detect when you're dealing with pages.

The diagram below shows how you must set up any parts of your app that need to deal with pages - generally, the settings pages that change the profile box. You also need to add the URL of your settings page to the "Page Edit URL" in your app settings.

FBPages_Small.png

Below is the original edited transcript from IRC where I explained how to do it, from what I've gleaned from what documentation there is, and my own experimentation. It may be ugly, but it may have details that are not addressed in my diagrams above. Enjoy. --42904324 03:28, 23 April 2008 (PDT)

Here's a very short version, with the basics. Below is the fuller transcript with more background and details.

(02:50:57 AM) fiveofoh: Looks like you specify a settings page
(02:51:20 AM) fiveofoh: Which gets passed a fb_page_id parameter
(02:51:24 AM) fiveofoh: And then you use that in setFBML
(02:52:01 AM) fiveofoh: instead of the UID
(02:52:05 AM) fiveofoh: I just tested it, and it worked
(02:53:13 AM) fiveofoh: It requires a good bit of refactoring of the various parts of your app that assume they're getting a UID
(02:53:18 AM) fiveofoh: But that's the basic idea
(02:53:49 AM) fiveofoh: Somewhere in the settings pages for your app is a Page Edit URL
(02:54:08 AM) fiveofoh: The box on the page will have an "Edit" link that will take you to that page, with a fb_page_id parameter
(02:55:32 AM) fiveofoh: So at the edit URL, you check for the fb_page_id parameter
(02:56:04 AM) fiveofoh: If it's there, you show a page settings page, and then set the box with setFBML, using the fb_page_id instead of uid
(02:56:28 AM) fiveofoh: You need to detect the fb_page_id and make any adjustments necessary
(02:58:17 AM) fiveofoh: if fb_page_id is in the params, give them a settings page that controls what's in their profile box, and a button that               
                        triggers a setFBML with the fb_page_id
(02:58:26 AM) fiveofoh: Otherwise do normal stuff
(02:58:39 AM) fiveofoh: Also, if fb_page_id is in the params, don't make them log in
(02:58:42 AM) fiveofoh: Cause that's obnoxious
(02:58:49 AM) fiveofoh: And unnecessary
(03:00:23 AM) fiveofoh: The page is your user
(03:01:20 AM) fiveofoh: fb_page_id IS your uid for the page
(03:01:35 AM) fiveofoh: Instead of calling setFBML(uid, blah, blah, blah)
(03:01:48 AM) fiveofoh: just call setFBML(fb_page_id, blah, blah, blah)
Params On Static Page (A page without authentication checks):
Array
(
    [fb_sig_in_canvas] => 1
    [fb_sig_request_method] => GET
    [fb_sig_locale] => en_US
    [fb_sig_in_new_facebook] => 1
    [fb_sig_time] => 1240397434.7488
    [fb_sig_added] => 0

    [fb_sig_page_id] => XXXXXXXXXXX

    [fb_sig_page_added] => 1
    [fb_sig_profile_user] => XXXXXXXXXXX
    [fb_sig_profile_id] => XXXXXXXXXXX
    [fb_sig_in_profile_tab] => 1
    [fb_sig_api_key] => xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    [fb_sig_app_id] => XXXXXXXXXX
    [fb_sig] => xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
)
Params On App Page (A page which require login):
Array
(
    [fb_sig_in_canvas] => 1
    [fb_sig_request_method] => GET
    [fb_sig_friends] => XXXXXXXXXXX
    [fb_sig_position_fix] => 1
    [fb_sig_locale] => en_US
    [fb_sig_in_new_facebook] => 1
    [fb_sig_time] => 1240397664.422
    [fb_sig_added] => 1
    [fb_sig_profile_update_time] => 1240321462
    [fb_sig_expires] => 1240484400
    
    [fb_sig_user] => XXXXXXXXXXX

    [fb_sig_session_key] => XXXXXXXXXXX
    [fb_sig_api_key] => XXXXXXXXXXX
    [fb_sig_app_id] => XXXXXXXXXXX
    [fb_sig] => xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
)

(full transcript)

(01:48:33 AM) swombat: pom pom pom... do I need to do anything special to set the FBML on a Page (as opposed to a profile)?
(01:48:44 AM) swombat: If so, what?
(01:56:07 AM) swombat: anyone?
(01:56:16 AM) swombat: I've read the wiki, but as usual it's confusing
(02:31:53 AM) swombat: seriously... is there anyone around who knows how to add a profile box to a Facebook Page?
(02:36:33 AM) fiveofoh: I'm trying to remember where I was reading about how to do it
(02:36:41 AM) fiveofoh: Cause I was going to try with mine
(02:42:12 AM) fiveofoh: http://wiki.developers.facebook.com/index.php/Facebook_Pages
(02:42:14 AM) fiveofoh: That's about all they have
(02:44:41 AM) swombat: yeah i've seen that
(02:44:46 AM) swombat: doesn't say how to set the FBML though
(02:44:56 AM) swombat: profileFBML obviously doesn't do it
(02:46:05 AM) ***fiveofoh created a page, there's nothing obvious
(02:49:12 AM) fiveofoh: Hmm, you specify a settings page
(02:49:24 AM) swombat: last Wall post: Thierry Droz (Montreal, QC) wrote
(02:49:24 AM) swombat: at 9:22am
(02:49:24 AM) swombat: There is no help here. Nobody from Facebook has been working on pages application since February...
(02:49:33 AM) swombat: ......
(02:50:53 AM) fiveofoh: Aha
(02:50:57 AM) fiveofoh: Looks like you specify a settings page
(02:51:20 AM) fiveofoh: Which gets passed a fb_page_id parameter
(02:51:24 AM) fiveofoh: And then you use that in setFBML
(02:52:01 AM) fiveofoh: instead of the UID
(02:52:05 AM) fiveofoh: I just tested it, and it worked
(02:52:10 AM) fiveofoh: And btw you can use your app page as a page
(02:52:16 AM) fiveofoh: You can add apps to your app page now :P
(02:52:16 AM) swombat: hmm
(02:52:25 AM) fiveofoh: So you could add a little sample box of your app to your app about page
(02:53:13 AM) fiveofoh: It requires a good bit of refactoring of the various parts of your app that assume they're getting a UID
(02:53:18 AM) fiveofoh: But that's the basic idea
(02:53:49 AM) fiveofoh: Somewhere in the settings pages for your app is a Page Edit URL
(02:54:08 AM) fiveofoh: The box on the page will have an "Edit" link that will take you to that page, with a fb_page_id parameter
(02:55:32 AM) fiveofoh: So at the edit URL, you check for the fb_page_id parameter
(02:56:04 AM) fiveofoh: If it's there, you show a page settings page, and then set the box with setFBML, using the fb_page_id instead of uid
(02:56:28 AM) fiveofoh: You need to detect the fb_page_id and make any adjustments necessary
(02:58:17 AM) fiveofoh: if fb_page_id is in the params, give them a settings page that controls what's in their profile box, and a button that 
                        triggers a setFBML with the fb_page_id
(02:58:26 AM) fiveofoh: Otherwise do normal stuff
(02:58:39 AM) fiveofoh: Also, if fb_page_id is in the params, don't make them log in
(02:58:42 AM) fiveofoh: Cause that's obnoxious
(02:58:49 AM) fiveofoh: And unnecessary
---------------
(03:00:07 AM) fiveofoh: So, you update it periodically then?
(03:00:21 AM) swombat: atm i have it updated on certain user actions and every 30 minutes
(03:00:23 AM) fiveofoh: And wait...the page is your user
(03:01:07 AM) swombat: but... you get both an fb_page_id and an uid right?
(03:01:11 AM) fiveofoh: NO
(03:01:20 AM) fiveofoh: fb_page_id IS your uid for the page
(03:01:35 AM) fiveofoh: Instead of calling setFBML(uid, blah, blah, blah)
(03:01:48 AM) fiveofoh: just call setFBML(fb_page_id, blah, blah, blah)
(03:01:50 AM) fiveofoh: voila
(03:02:02 AM) swombat: ok, so basically, "Facebook pages is all transparent uses fbml blah blah blah" "Oh but btw you need to build a completely 
                       different piece of code to handle this new type of user"
(03:02:18 AM) swombat: (not angry at you btw :-P)
(03:02:43 AM) fiveofoh: Yeah pretty much
(03:02:46 AM) swombat: this sounds really quite tedious and error-prone though
(03:02:50 AM) fiveofoh: Yeah it does
(03:02:56 AM) fiveofoh: Which is why I haven't done it on my app yet :P
(03:04:23 AM) swombat: so, facebook pages for devs: 1) undocumented, 2) overlaps with existing concepts and objects, 3) requires duplication and 
                       alterations to existing code, 4) users need to take multiple complex actions to be able to fully add the box to their page
(03:04:28 AM) swombat: brilliant
(03:05:13 AM) fiveofoh: You'd just do a check for fb_page_id in your post-add page
(03:05:20 AM) fiveofoh: Once again, messy duplication
(03:06:03 AM) fiveofoh: What I might end up doing is if I see fb_page_id, just forward to a separate page, so it's not all gross and duplicated
                        and ugly
(03:06:27 AM) swombat: hmm
(03:06:36 AM) fiveofoh: like at the top of index.php
(03:06:49 AM) fiveofoh: check for fb_page_id, if so, forward to index_page.php?pageid=blah
(03:07:05 AM) ***fiveofoh considers cleaning up and putting up this IRC transcript on the wiki
(03:07:15 AM) swombat: yeah that sounds like a good idea
(03:08:10 AM) swombat: this is what I'd call a half-assed feature :-P
(03:08:15 AM) swombat: facebook -1

Additional Documentation