MVC Profile Tab on Fan Page

Mar 17, 2010 at 9:26 PM
Edited Mar 17, 2010 at 9:48 PM

My ultimate goal is to create a dynamic tab on a fan page.

First I would like to be able to access photos associated with the page, but I would also like to use the limited data available (I believe) from the user viewing the page.

When I add the tab page to my user profile, I can access user info and successfully create a "Hello Hector" page, but this requires allowing access to the app (not desirable on the fan page tab).  I can live without the page user's data if this is not possible.

When I try to access the photos associated with the fan page, I get various errors associated with what I think might be the issue (no session key). I have tried all sorts of combinations of the FacebookAuthorization attribute without success.

Tried the following:


//nothing at all (Intuitively this is the correct one based on my understanding. I don't wish to prompt user on tab page)

[FacebookAuthorization(IsFbml = false)] //doesn't return when used on fan page tab

[FacebookAuthorization(IsFbml = true)] //gives fb:Redirect error

When I step through the simple code on this page, the call to this.GetApi() does not raise error, but the returned object's SessionKey is empty, which cause calls to api methods to fail.

Any thoughts or links to mvc samples using profile tabs would be appreciated.

May 9, 2010 at 2:17 PM

Hi, Did you ever find the answer to this?

May 9, 2010 at 3:28 PM

Hi Arran,

//nothing at all is correct

Casual visitors to an arbitrary fan page will not have given (or be likely to give) your app any permissions.

Because Facebook does not pass the user's id to the fan tab page by default, the toolkit does not populate the Session object's SessionKey or UserId properties needed to make api calls.

To overcome this you need to generate an infinite sessionkey for a userid. I can't help right now with the procedure to do this (forgot), but you should be able to find some help searching on "facebook infinite session". I did this once for me and shared the generated key among all the pages hosting the tab. This worked for me because I only needed access to public data for the hosting page and could get this without a specific key for the hosting page.

Some like this:

string InfiniteSessionKey = "your infinite session key";

//ID associated with generated infinite session key
long UID = 123456; 

//ID of page hosting tab
string PageID = Request["fb_sig_page_id"];

var api = this.GetApi();

api.Session.SessionKey = InfiniteSessionKey;
api.Session.UserId = UID;

//Get a list of albums for page hosting tab
var AlbumList = api.Photos.GetAlbums(PageID);

May 11, 2010 at 12:51 PM

I am trying to do something similar along the lines of a "dynamic profile tab" where a fb user can add my app to their profile and add a url to the tab. I have most of it done but can't wrap my head around how the profile tab needs to be structured. I assumed I'd need to store a the user's profileID and the URL's in a database, but no sure how to get that working. ANY help or code snippet would be greatly appreciated!

May 11, 2010 at 2:37 PM

Assuming you are adding tab to user's profile as opposed to a page, I believe you can access the profileID of the user hosting the tab as follows:

//ID of profile hosting tab
string ProfileID = Request["fb_sig_profile_user"];

//ID of page hosting tab
string PageID = Request["fb_sig_page_id"];

One or the other will be passed depending on whether the tab is hosted in a profile or page. It's up to you to use it to retrieve whatever you have stroed based on the ID

May 11, 2010 at 2:57 PM

My issue i'm sure is related. Currently using FDT-50207 build. If I run my simple app just by its self on facebook in the app area (FBML) it is working a treat. However if I add it as a tab on a public facing "Page" I get the following error.   Ideally, anyone visiting my public "Page" should just be about click on the tab and see my app. I don't need any of their person profile details (as yet)

Errors whilst loading page from application
Runtime errors:
fb:redirect: redirect forbidden by flavor TabFBMLFlavor

There is no <body> etc code. All the call backs are correct (I think)

MVC code just pump out a simple bullet list of links:

[FacebookAuthorization(IsFbml = true, ApiKey = "xxxxxxxxxxxxxxxxxxxx", Secret = "xxxxxxxxxxxxxxxxxxxxxxxxx")]
        public ActionResult Vouchers()

            using (websiteDataContext db = new websiteDataContext())

                ViewData["vouchers"] = db.website_FacebookSproc().ToList();

           return View();

Any help would be really welcomed.

May 11, 2010 at 5:03 PM
Edited May 11, 2010 at 5:04 PM

Hi Arran,

You need to remove the "FacebookAuthorization" attribute. The intial request for a tab page is anonymous which means authorization is not possible.

Based on the sample code you are not accessing any data that requires knowledge about who is using or hosting the tab, which means you don't need to call the facebook api at all. The sample stuff above would be needed only if you need to use the facebook api to access facebook data.


May 11, 2010 at 5:13 PM

Hi hmaceachern.

Hands up, I could not see the work for the tree.. should of guessed. I'll try without 'FacebookAuthorization' tonight. I was hoping it was me being stupid.

Many thanks


May 12, 2010 at 12:50 AM
Edited May 12, 2010 at 1:32 AM

hmaceachern., Can you tell me the requirements to simply get this Pageid to display on a label on an aspx page. For example, do I need to implement Facebook.Web.CanvasFBMLBasePage?

Is there a sample of this functionality somewhere? Code sample would be really helpful. Thanks.

May 12, 2010 at 4:31 AM

nevermind, I had to just implement CanvasFBMLBasePage and remove the RequireLogin= true.

May 12, 2010 at 8:12 AM

hmaceachern thanks. It's working a treat now. I was just dumb.

Next challenge is how to get the Tab to appear as a Profile Box on the left col of the Facebook page. Using the static FBML app it offers me the choice of tab / box , but using a my own app (tab) I can not get the option for Box.  If i'm reading the FB insturction correctly (ha) I think they are trying to pharse this option out.

Does anyone have any ideas for this, Public facing Fan page.



May 12, 2010 at 9:48 AM

The profile box feature is going away very soon. I would not waste any effort on it.  I don't know why it doesn't show up as an option (on the application settings dialog from the menu i assume you mean). Just a guess... Maybe you need to use the setFBML() to cause it to show as an option.

Again, I wouldn't waste my time. It is already past the timeframe facebook originally announced for the removal of this feature.

May 12, 2010 at 9:51 AM

Cheers for confirming the question. FB is all new to me.  Next step is building user data profile stuff.