Facebook requests - how to pass through custom variables from the Requests page - 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?

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.

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.

The only option I know of is making adding the app and linking with friends two separate processes.

Related

Tracking user activities on facebook

I've created a Facebook page and implemented an application for it too. Now, my aim is that, a user must like and share page with at least one friend to be able to participate/to get access to the app and consequently use it (play the game). Or simply force a user to like and share the page. Can you please tell me if this is even possible and how it can be achieved?
When user visits your Facebook page, you receive signed_request , which contains some information about the user, including whether or not the user liked your page. For share, you will probably need to implement send dialog. In documentation it is said that user takes action (send or cancel) he will be redirected to url you set up, and if the action was "cancel", there will be an error.
So you will probably need to create db where you store user id and whether or not he shared your page before (since you can check if he liked the page at any time).

Send user to friend's profile within canvas app via automated URL in emails?

Question from a product management perspective at a company which will offer a complete UI of our product within our Facebook canvas app.
The desired functionality of a feature would be:
Registered user receives email suggesting friends to recommend our service to.
Email contains generated URL to our Facebook canvas app.
When clicked and opened, canvas app lands on page with information about suggested friend.
Is it possible to automate a URL that would trigger this?
You can pass information in to you canvas app using the app_data parameter in the URL. The passed app_data is then made available as part of signed_request. You can find more at http://developers.facebook.com/docs/authentication/signed_request/
As an example, you could use the following URL
http://apps.facebook.com/mycanvasapp?app_data=some_app_data
The app_data variable of signed_request would then contain the string
some_app_data
If you need to pass something complex though app_data, I believe the most common method is to pass it as a JSON formatted string (see http://www.json.org/ for more on JSON).

How to receive Facebook App id on a canvas page

Is it possible to get the Facebook app id on my canvas page?
So I am here: apps.facebook.com/myappspace
and in my index.php I want to get the FB App id now. Is this possible? The only way I figured out was when I can get the signed_request, because a user already authenticated my app.
But let's assume an unauthenticated user visits my canvas page. Any way to get the FB App Id?
P.S.
It's not possible to write it into my php-file, because I use the same code for several Facebook Apps, so I need to find our now what App is used to show individualized content.
In short this is not possible without getting signed_request.
Actually you not really have to place this information in the code, but some configuration files, which should be different for every application instance, have appropriate permissions and without public access for sure.
You can decide which configuration to use based on application hostname/ip (any other way to identify which application it is).

Workflow for a message/item sending Facebook canvas app using new Request 2.0

Working on my second app and the first using the new Request 2.0 and other recent features.
I've managed to get the app to log a user in and grant the extended permissions.
My app is simple: I want a user to be able to send a message to a friend along with a user-selected graphic to go along with the message. I guess the basic metaphor is a gifting app.
I'm not wrapping my head around the workflow especially as examples using the new Request 2 dialog seem few and far between.
Here's what I'm thinking the beginning of the workflow looks like:
User arrives at app page. Logged in, permissions granted if needed
User selects a graphic (via an html radio button form) to go along with message they enter into an html text form
User selects friend(s) to send the message/graphic to.
I'm assuming I should toss the senderid, receiverid(s), link to graphic (or id), and message into a database.
How do I get the info from my users' selections? Does hitting Send Requests on the FB dialog POST the FB and form POST info to the same page so I can read them via PHP $_POST variables?
When the person receives the request, they accept it, but how do I get them to go through the requests outstanding and display the graphic and message? i.e. Archie logs in and has 6 friends sending him items through my app. How does he, in FB methods, see the message/items that Veronica, Betty and Jughead have sent him?
I don't mean that in a basic way. I know how to do this all if I was just writing a PHP app on my own site. I'd be finished in a few minutes. The part that's causing a head-shaped dent in my desk is trying to work out how it works adding Facebook to the workflow. I've been looking for examples and tutorials but they seem to be out-of-date to the new methods FB wants us to use.
Thanks for any pointers!
When a user follows a request you have access to that request ID. If you need to access additional requests the user needs to "Connect" with your app so you can read that info from the user object. The request ID for the acted upon request will be available to you on your canvas page and it will be up to you to develop a work flow that authenticates the user to be able to access any other requests for that user.
The related blog post that discusses the process is available here:
https://developers.facebook.com/blog/post/464

Facebook page apps - Authorizing a user

I can't seem to find exactly what I'm looking for. We're trying to build an app to run solely on a Facebook Page. We want to show a landing page if they don't Like the page, and the contest entry form if they do. This functionality works.
Before showing the contest entry form, we'd like to authenticate the user viewing the app so that they can just hit "Enter the contest!" and we can automatically pull a name/email address.
Any of the methods of authentication I've seen described, including through the Facebook Developer docs, don't work at all.
I saw something that said they need to interact with the app first, then you can get the id, but that doesn't work either. I also don't get the page id passed with the signed request.
Its also pretty unclear whether I should be using an iframe or just FBML.
Could anyone point me in the right direction, please? Thanks!
You need to create a fan page and add the FBML plugin to that page, then you will need to insert a short code that will determine if a facebook user has clicked 'Like' or not and by determining that you will decide weather to display the content of the landing page or not (using an iframe). You will probably like to also set the FBML box that you create as the default view for members who didn't press the 'Like' button yet, you can change the default view in your fan page settings.
On the iframe, you will need to use the Facebook API if you want to retrieve any user information from Facebook, for that, you will need to register a new application with Facebook. Go to developers.facebook.com for the API integration and app registration.
Also, what do you mean when you say:
Any of the methods of authentication
I've seen described, including through
the Facebook Developer docs, don't
work at all.
Well, it appears you can't do it that way. The client was very specific in wanting that functionality but we ended up convincing them to go for a redirect to the canvas page to have the app authorized and the contest entered instead.