add a tab to facebook page programmatically - facebook

I have a site that hosts music (stereokiller.com) - a sample band page would be http://www.stereokiller.com/rapture .
I am attempting to create a facebook application that will insert a new tab into a user's band page on facebook loaded with the player and some other information from my site. However, i'm not sure how to pass the iframe app any parameters to determine which band information to show? I'm aware of the FB_SIG_PAGE_ID which I could then get the owner page name from the Graph API, but if there are multiple bands on my site with the same name then we could have issues.
[solved]
I figured it out.
do an http call to graph.facebook.com/me/accounts?access_token={access token}. loop through results with the access token retrieved through the prior call, then do http post to graph.facebook.com/{PAGE_ID}/tabs with the form param {app_id} for the app of which you want to add.

You can install a profile_tab at the end of the current list of installed tabs for a page by issuing an HTTP POST request to PAGE_ID/tabs with a Page Access Token:
Parameter Description Type Required
app_id ID of the application for which to install the tab. string Y
If the create is successful, you get the following return:
Description Type
If the create succeeded boolean

Related

Facebook review Submission for "manage_pages" permission

Can anyone please help me to submit to get approal for "manage_pages" permission..?
I haved tried on my best but always get the repsonse like:
"Your Page Tab links to a different Facebook URL. Go to the app "Settings" tab >> find the "PageTab" section >> revise your Page Tab platform."
As my case, I have an ecommerce system which allows users create an online store automatically by few step.
For example, ecommerce system is hosted at URL abcd.com. I create a store name "TEST", so I would get a sub domain test.abcd.com where I can access to my "TEST" store
So this means that, abcd.com just be a general domain, for each different store will have one separate sub domain
In PageTab section of my Facebook App, I config detail as below:
- Page Tab URL: http://abcd.com
- Secure Page Tab URL: https://abcd.com
I create a FanPage name "Testing FanPage 01" and try to integrate my store ( test.abcd.com ) to this FanPage
It works prefectly although the URL of page display in iFrame is test.abcd.com which totally different from the Secure Page Tab already defined before
The whole process can be explain as: when Facebook's proxy post to abcd.com , I will do some process to detect and redirect to test.abcd.com
I think, the problem is that the page URL displayed in iFame is completely different from the Secure Page Tab already defined before...?

Callback from Facebook app as a tab app on multiple pages

Salon owners can create an account with their salon information on our platform and they get a page that they can use as a tab app.
I want to be able to serve all these pages from one app instead of having to install each one seprately and I also want to make the life of the salon owner easier by helping them to install the tab.
I know about the link I can create to help them install the app and I know that when a visitor visits the app that facebook will send the page ID. So far so good.
https://developers.facebook.com/docs/appsonfacebook/pagetabs/
But how do I make sure that when the salonowner follows the link to install the app that I get the page ID back (through callback or other) so that I can register which page ID belongs to which salon account.
I've read sone 2011 article about a callback but I can't find any recent info on this.
I think it should be possible as a lot of sites offer easy fb apps to businesses.
Any help would be welcome!
EDIT: Could this last piece of info in the Facebook link above be used to do this? I don't quite get it yet.
In addition, your app will also receive a string parameter called app_data as part of signed_request if an app_data parameter was set in the original query string in the URL your tab is loaded on. It could look like this: "https://www.facebook.com/YourPage?v=app_1234567890&app_data=any_string_here". You can use that to customize the content you render if you control the generation of the link.
Well... Preventing users from adding your application to their page is impossible. You can't prevent that.
What you will be able to do is to detect who has added your application and according to that, change the content (or not display it at all). So you'll have to start with a list of "allowed" page_ids to match to the accounts you want.
Your application will receive a signed_request each time a user arrives at your application (within a page). Inside that signed_request is information not only on the user but also on the page that the application is on (provided it is a page tab app).
Once you have obtained the signed_request, it will hold a page key which contains:
A JSON object containing the page id string, the liked boolean (set to
true if the user has liked the page, false if not) and the admin
boolean (set to true if the user is an admin of the page, false if
they're not). This field is only present if your app is being loaded
within a Page Tab.
So you'll be able to access the page_id from within this variable and make a decision on the type of content you want to be displayed.
Ok, after running some tests I found out that when you add a URL as 'next' parameter to the install URL Facebook will send the admin(user) back to this URL while adding an array to the request containing all the page Id's the app was installed to.
Like this: YOUR_CALLBACK_URL?tabs_added[ID]=1
Proved to be quite easy in the end

passing variables into new page tab installations

I would like to build a customized Facebook page tab for other page owners to instal onto their Facebook pages. Each page tab will need to have its own ID in the links that lead out of the page tab in order for us to track that page activity.
For example each page tab will have a list of products that link to the relevant product pages on an external website. Each of those links will have a unique ID parameter to we can track clicks and purchases. [e.g http://www.mydomain.com/products/product123.aspx?userid=12345]
So I need to create the userid variable in the link. Possibly using GET (or Request.QueryString for asp) to receive from the initial page tab installation.
From what i can see I might be able to use the app_data parameter to pass data over to the page, but when i tried it, it didn't work.
This is what i am using to install the page tabs
[https://www.facebook.com/dialog/pagetab?app_id=YOUR_APP_ID&app_data=12345]
I thought that this will pass the userid over to the new page tab, but it doesnt seem to work.
If anyone could point me in the right direction i would be very grateful.
Cheers
From what i can see I might be able to use the app_data parameter to pass data over to the page, but when i tried it, it didn't work.
This is what i am using to install the page tabs [https://www.facebook.com/dialog/pagetab?app_id=YOUR_APP_ID&app_data=12345]
But you are aware, that appending &app_data=12345 does not mean you will get a GET parameter by the name 'app_data', right …?
The app_data will be passed as a property inside the signed_request parameter – so you’ll have to decode that one, and inside you’ll find your app_data value.
Why does 'each page tab' need to have an ID?
The Page ID should be enough for you to determine which content to show (and it's passed to your app on each page load via the signed_request, and the page ID is also passed back to your app in the callback to the pagetab dialog
You could also request manage_pages Permission from the user to determine the list of pages they administer and if your app is installed on each

how to get page id when installing a iframe page tab on facebook?

I want to create a simple facebook page tab. Where i want that, if a user install this app to a page the page id will be stored in my database. Then i will show different content for individual fb pages. I read some documents where it is mentioned that signed_request could be used to get the page id. but signed request it received after the page is loaded into some fb page.
As anyone can install my app it is not possible to know who is going to install the next. but i have a plan to show different pages(from my server) in different page (in Facebook) tabs.
Just noticed that it is now an array, named tabs_added . The key of the array is the page ID and the valude is 1 (true) for tabs added. This would give you the idea that the other page ID keys would be in the array with 0 (false), but they are not passed.
<?
// grab all keys in an array
$aKeys = array_keys($_REQUEST['tabs_added']);
// take the first key - this is one of the page ID's the tab was added to
$sFirstKey = array_shift($aKeys);
?>
Courtesy dk1, precisely $_REQUEST['fb_page_id'] made it work.
Facebook will call your Application URL when someone is installing you app as a page tab. Do there some $_REQUEST logging to find out which params Facebook is sending in that case. There is one value that identifies the page where the application got added.
I've done this already but have no sample code here atm to show you.

Facebook SDK install APP with install confirmation

I am looking for help to validate when a Facebook APP has been installed. I am currently using PHP SDK to have the clients sign in and in the same manor I would like for them to return to the site once the APP is completed and installed correctly.
Is there a method to use this link and have it return with the client id?
https://www.facebook.com/add.php?api_key=XXX
You should not use https://www.facebook.com/add.php?api_key=XXX for any cases other addition of application to page as a tab (and even this is undocumented).
If you're using PHP-SDK you should use Facebook::getLoginUrl to log user in, which support redirect_uri parameter so you can add client id as argument to this URL
Update:.
As it turns question is about adding application tab to page you should be using Add Page Tab Dialog to provide user with a way of "installing" application to page without leaving your app.
You can refer to answers on How to add tab application to a page with the "new auth dialog" for more info.
Update 2:
How to reach applications running as Page Tab described in "Integration with Facebook APIs" section of Page Tab Tutorial:
your application will also receive a string parameter called app_data as part of signed_request if an app_data parameter was set in the original query string in the URL your tab is loaded on. For the Shop Now link above, that could look like this: http://www.facebook.com/YourPage?v=app_1234567890&app_data=any_string_here. You can use that to customize the content you render if you control the generation of the link.
You not required to add app_data, just use v=app_APPID to link to your page tabs (Facebook itself using sk instead of v, both works).