Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Facebook requests - how to pass through custom variables from the Requests page

Tags:

facebook

I am building a facebook app that has a send to friend feature in it.

Each user is given a specific userkey that identifies them and them alone.

So Person A invites person B.

So when person B gets the invite, when they click ACCEPT, we pass the referrer userkey in the URL… e.g. http://mydomain.com.au/return_user.aspx?referrerkey=iuahsduiahsdfuiha

So when person B has already installed the fb app, the referrerkey variables is passed back to our site, so we can manage the link between the 2 users there.

However if person B hasn’t added the app. And Person B clicks the ACCEPT button on the invites page the user has to be take through the “Allow Access” page, from there, they are directed back to the APP home page, with none of the variables I need. E.g. the referrerkey.

So how can i get this to work for both users that have already added the app and havent added the app?

like image 628
Darren Clark Avatar asked Jun 25 '10 05:06

Darren Clark


2 Answers

Yes, the request 2.0 flow will always land the user back on the canvas home page- no avoiding that.

When you create the request, though, you can add "data" parameter to the request object, and put whatever data in it you want. Then, on your canvas' home page, query for data in the signed_request. Setup a variable like, user_id or some app specific variable, game # or something. If it's present, then redirect to a more applicable page or route.

You can identify entries to your app- differentiating it by other non-request redirects to our canvas home page-- because there will be request_ids present in signed_request.

Note, you can also take the request id, and get the object from Facebook, which will have the "from" referrer. So you don't need to pass that around.

like image 77
Anna Billstrom Avatar answered Sep 22 '22 09:09

Anna Billstrom


Assuming you're using the PHP facebook SDK and a canvas app, You're probably using require_login() to redirect the user to the auth screen. By default, the auth screen will send the user back to the canvas URL you set in the app settings.

To get around this, pass a GET parameter called "next" with a urlencoded URL as the value. If you're lucky, your version of the facebook SDK may have this code preset but not active. Look for ‘&next=‘ in the Facebook class.

like image 21
Mike Sherov Avatar answered Sep 23 '22 09:09

Mike Sherov