Here is a scenario to explain my question:
Lets say the app is a simple "suggestion box." The company installs the app and adds it to their facebook page. Then a user sees it and decides to leave a suggestion.
Once they click on the app, the app will ask to be authorized. Once they authorize it, I have no trouble sending their FB username to my server.
But how can I capture the user id of the company on whose page they first clicked on the app before they installed it?
I want the app to capture both the username of the person who is authorizing it, and the username of the person on whose page he click on the app.
Some users may install the app from the app center directly, in which case this field may be blank, but every time someone clicks on the app on someone's facebook page, I need both pieces of information to go to the server.
Any ideas?
You'll be able to find this information in the signed_request passed to your application. It contains a page parameter that contains information about the page that the application is installed on. If the page exists, then the user is accessing your application from a page tab, if not, it would be safe to assume that the user is interacting with the application on its canvas url - https://apps.facebook.com/yourAppNamespace
Facebook Signed Requests -
A signed_request parameter is used by Facebook to pass data to an application in a number of different scenarios...
Related
I want to build a facebook application and don't know how to plan it. A facebook user should find that application and click a button there, something like: "Add this Application to your facebook page". After that (or when the user first opens the app tab) the user will be asked to log into an external website. When the credentials are okay and the user is the owner of that facebook page/tab then this external web application will display an external profile page of that facebook user (the owner of the facebook profile the app has been put in). After that the user doesn't have to log in anymore and every user that visits that tab will see the external profile of that facebook page.
...To make it more clear an example:
User Foo has got an account at example.com and a public visitable profile there example.com/profiles/Foo. User A has also got a facebook page. Now example.com tells its users that they developed a facebook app to integrate their example.com-profiles into their facebook profiles. So the user A opens that apps page, clicks a button, logs into example.com and now has a new tab at her facebook page that contains example.com/profiles/Foo. If user B visits the facebook page of user A, he will find the example.com-profile of user A (not B) in the application tab.
What I would need is the following information:
How can I make an application available for the facebook users?
Update: found this tutorial: http://www.hyperarts.com/blog/facebook-removing-app-profile-pages-on-feb-1-2012/
Is it possible to make something like an installation process of an app? Otherwise if user A clicks the button to integrate the app into her page and user B opens the tab before user A could open it and log into the example.com, then user B could log in and his example.com profile would appear in the facebook page of user A. Or how can I solve this problem.
Next problem is that--I think--the URL of the application will be the same for all users, that integrate this app into their profile. So I would need to be able to detect the facebook page of a app request.
Update: I will be able to read the page ID from the signed request. Problem seams to be that the page administrator must know his/her page ID, but I think it will be possible to retrieve it through the graph API (if it is not part of the URL).
I have a page tab app. The authorization works fine - the user clicks the authorize button on the app, the OAuth dialog pops up, they authorize the app, it redirects back to the page tab and the user goes about their merry way, using the app.
I need to know one thing, and for the life of me I cannot find a real answer - is it possible to identify the one http request that occurs immediately after the user authorizes the app? I simply want to log the user's data when a user authorizes the app, without having to hit the database and test if the facebook user id has already been logged. You'd think this would be easy...
THank you for your time.
Yes, you can do with help of the signed_request
Read here how to handle authroization in page tab.
simply, when user comes to app
- check user_id exits in signed request, if not exist, then he has not authorized.
- Store some variable in session
- when user logs in, check whether session variable exists or not. if exists, its a fresh install.
With the changes for Facebook Apps coming on October 1st, I am having trouble confirming that our Canvas/Tab app will/will not work as expected.
When a user first loads the tab with the app, I'm expecting facebook to send me parameters of "fb_sig_profile_id" (which I believe should be the ID of the Page) and "fb_sig_app_id" (the ID of the APP).
I DO NOT need/want to authenticate users or access UserData/Graph etc. I am simply displaying content on my end based on these parameters.
If this is no longer the case and Facebook is not going to be sending me these parameters, can someone point me in the direction of how I can get this data.
Thanks
When building Apps On Facebook kind of apps, Facebook will send a signed_request which will contain the data you need:
When a user navigates to the Facebook Page, they will see your Page
Tab added in the next available tab position. Broadly, a Page Tab is
loaded in exactly the same way as a Canvas Page. Read more about this
in the Canvas Tutorial. When a user selects your Page Tab, you will
receive the signed_request parameter with one additional parameter,
page. This parameter contains a JSON object with an id (the page id of
the current page), admin (if the user is a admin of the page), and
liked (if the user has liked the page). As with a Canvas Page, you
will not receive all the user information accessible to your app in
the signed_request until the user authorizes your app.
Reference.
I am making a Facebook App which will be only used for Facebook Pages.
I need to provide a post-authorize URL to make some action on Database when a user adds the app to their page.
But i cannot find any place to enter the URL.
Someone can help me ?
EDIT: User will only Add App to their page from Application Profile Page on FB
There is no such thing as "post-authorize URL" for applications working as Page tab. You will never know identity of user who added your application on page via application profile page.
Adding application to page doesn't mean that owner of page authorized the app.
Signed request contain information about page and user interacting with page tab application so you may know if user is admin of the page, liked the page and some additional details, it will include personal details only if user authorized application which should be done as separate step.
The way I'd do it:
List all the PAGE ID on which your user is admin:
FQL: select page_id from page_admin where uid=me()
When a page load your application, using the data contained in the signed_request POST parameter, look if the current page is a new page (just assign a boolean in the database to know if the page is already using the application or is new), and if the page is in fact using the app for the forst time, look if you have the admin in your database (remember? you have linked the PAGE ID and the ADMIN ID together in #1)
From there, you can do whatever you want: display a "application not yet authorized" instead of the normal app in order to wait for the user to pay you, etc...
Forgive me if this has been asked before, but I was unable to find an answer to what seems a simple question. I have an app that is authorized to a user & user's fan page via a process from a website I've constructed. The process is this:
Visit Website --> authorize website to view list of fan pages --> Select Fan Page to install app to --> Authorize app to user account --> Authorize app to Fan Page
I've got all that working (a process, let me tell you), and everything functions as intended. I'm working on an admin interface to manage the app which is not housed in the Canvas App location but on the website itself. I haven't found a way to figure out if the app is installed or not. It appears that the Graph API / FQL doesn't support this.
My two issues are:
I have the user id & the fan page id but I can't figure out whether said fan page has my app authorized or not. Depending on this answer will determine whether I show the "Install This App" panel or the Administration panel.
I've read that the best method is to store the userid when the app is initially authorized, but after the app is authorized, the user is sent to the Fan Page's Wall and I can't figure out how to notify my iframe app.
[edit] I misunderstood your question and thought you had less implemented than you seem to have: If you have manage_pages permission for a user, you can get the Page access token for each of their pages, and access a list of apps currently installed as tabs on that page - the instructions are at https://developers.facebook.com/docs/reference/api/page/#tabs
[/edit]
Each request made to your app's 'page tab url' will include a signed_request parameter.
The method to decode it is explained at https://developers.facebook.com/docs/authentication/signed_request/ - when your app is loaded on a page tab you'll get the 'page' parameter.
So:
The first time the tab provided by your app is loaded on a new page, you can detect the page ID from the signed request.
This callback will also tell you if the user currently looking at the page tab is an admin of that page (which can be useful for your own edit interface, if applicable)
If you haven't already got an interface where the app user tells you which pages they admin you can get a list of all the pages that user administers by accessing the 'accounts' property on their user object (/me/accounts in the Graph API) once you have the manage_pages permission
can you keep track of who has the app authorized in a database on your website?
i.e. call a script on your website server from your app that returns whether or not the user has authorized the app.