views:

153

answers:

2

Firstly apologies for the length of this question, and for asking about facebook API ( seemingly one of the most inconsistent api's in the world... ).

The Situation: We're producing an FB product 'community' - type page for our client, featuring standard facebook tabs, one of which embeds a flash game. At the end of this game we'd like to be able to share the users' final score via a wall post, and also invite friends to challenge the score.

Firstly - the client is insistent that the game appears on a tab within the page, so moving this all to an application ( eg: apps.facebook.com ) is sadly not an option. I'm aware you can embed an application on tab instead of static FMBL, but have tried this and the result is essentially the same or fails ( the tab imposes stringent restrictions on what can be rendered, enforcing the use of FBML and negating the FB:Iframe tag for starters ).

Currently we're embedding this game on a static FBML tab, using the fb:swf tag and fbjs-bridge to enable some simple interaction on the tab ( navigating to a new window etc. ). We've also tried the fbjs embed approach, and making the game into an application and adding that as a tab on the page. In all cases, there seems to be no way to get the UID of the viewing user when in the tab environment ( despite the fact that they must be logged in to see the page in the first place ). The game itself is flash AS3, and I've got the option to use the FB AS3 api. Using this approach the best process I've managed to come up with so far is outlined below:

0) Create a seperate application with the sole purpose of dealing with score sharing etc.

1) User Clicks 'Share my score' at the end of the game on the TAB page.

2) SWF does the standard facebook 'login to application' request by opening a new tab.

3) User confirms this action and closes the new window.

4) User clicks yet again within the flash game to confirm that they have logged in.

5) SWF performs the facbook.verifySession() and opens yet another window requesting permission to post on the users' wall.

6) User confirms this and is once again taken back to the game.

7) SWF listens for 'FacebookEvent.PERMISSIONS_CHANGED' and posts to the wall once this is confirmed.

Since there is no way to verify whether the user has added the application when loading within it a tab, its likely they would have to follow this process every time they want to post a result from the game, which is hideous. The main problem seems to be that any RIA residing on a FB tab recieves no useful information within the OAuth token for that tab, in contrast to an RIA sitting on apps.facebook.com which gets all the information I need within the request headers.

Put simply, I need the simplest, most straightforward way to make a FB wall post from within an FB Product page tab, whether using FMBL, FBJS, AS3, ASP or any combination thereof.

I've seen this: http://stackoverflow.com/questions/3674923/facebook-share-or-publish-dialogue-from-page-tab-closed which is indeed the same question I'm asking, but the answer is unclear, and it doesn't seem that it would solve my problem.

Many humble thanks for any help.

EDIT - tags in question made it go weird :)

A: 

Using the <fb:share> tag will do all of that for you. If you are not logged in and you click on the <fb:share> link, it will ask you to login, if you haven't accepted the application yet, it will then ask you to accept it, then post to their wall what you want. I have done this with my site to share products not game scores but it can be done all the same.

EDIT:

Check out the Graph API for publishing. If you are using flash, I would recommend using the Facebook Flash SDK

jostster
Thanks for the answer, but I need to be able to call this functionality from within the flash application. I was wondering whether the same function can be made via an FBJS call? That would be the best solution for me but i've not seen that done anywhere
bharling
@bharling I updated my answer.
jostster
@bharling: Did jostster's answer work for you? I am interested in the solution as well.
goliatone
+1  A: 

FB tab application SWFs receive a session key in flashvars, which can be exchanged for an oauth token! http://fraserhobbs.com/2010/07/flash-facebook-graph-api-in-tabs/ Really helped me out.

crickkills
If this doesn't work, I'd suggest using iframe app (can enable tab) and using the js sdk to make calls out to graph api from flash. Should be pretty seamless to make the calls in the context of user without any work arounds.
Jason