Facebook: Add an external profile into facebook - facebook

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).

Related

how to capture where facebook user clicked to install my app

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...

Facebook Permissions Dialog in Page

I've created an app that works fine, however if the user has not authorized my app yet, they have to do the following (assuming they are in facebook AND logged in) -
go to my app
click login/authorize
popup with facebook permissions opens
accept in the popup
However I noticed with Zynga games like Mafia Wars 1/2, Farmville etc, when you go to the app, if it hasn't been authorized, it takes you straight to the permissions which is in a PAGE and not a popup, thereby eliminating one step. Also, the permissions dialog is full width, there is not app sidebar.
Does anyone know how I can duplicate this flow? It would be much easier to have users authorize within a facebook page rather than through a popup. How can I get permissions inside the page?
thanks in advance
Once user visit a Page tab with your application you can check if he is connected with your application by comparing Page ID with User ID in signed_requests, for unauthorized users ID's will be same. In that case you can start authentication flow by redirecting user's browser to "login url".
If you want it to be full page just do the redirect with JavaScript like this:
window.top.location = 'https://www.facebook.com/dialog/oauth?
client_id=YOUR_APP_ID&redirect_uri=YOUR_URL&scope=COMA_SEPARATED_PERMISSIONS'
If you using PHP you can construct Login URL by calling Facebook->getLoginUrl method.
Read the docs on Facebook authentication

can't find post-authorize URL on facebook APP page

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...

How to determine if an app is authorized to a fan page

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.

Automatic login to Website when User login to Facebook based on cookie

I'm using the Facebook Graph Toolkit and developing ASP.NET website.
I want to create and design a website that has registration that will use a Facebook account as an alternative to my website login/registration.
I am thinking of just storing the Facebook User ID who has approved the use of the FB app in order to identify the user for next time when he/she logs in to my website using his Facebook account.
Scenario here is:
Any browser, user already logged in to his Facebook account (say browser Tab no.1).
Same browser, Tab no.2, user visits my website (he has already registered to my website using his Facebook account, as I store his Facebook ID).
Upon his visit to my website home page, the top corner will display his account name (this indicates that he has logged in to my website even though he has only logged in to Facebook, but never visited my website and clicked on the Login button).
So my question is, how to achieve the scenario of step no.3?
It's quite easy but you need to do some research first. Research will better help you to understand each and every point.
Go to the Facebook Developers API Reference and do some reading.