Force facebook app to use page tab iframe - facebook

I have an iframe facebook app currently running on a page tab. Unfortunately, when people share some of the links within the page, the resulting shared links send users to the original content on the server and not to the facebook page tab. How can I force users who arrive directly at the URL into the page tab iframe?

I found the solution: basically you can use the facebook javascript api to detect if you are within the iframe. If not, redirect. Here is the code:
// Test if canvas page loaded
var obj = FB.Canvas.getPageInfo();
// Now redirect to page if not
if(obj.clientHeight == 0) window.location = 'http://facebook/page/url/';

Related

How to open facebook page inside iframe

I want to open Facebook page inside iframe but does not render page when I try to just include IFrame with src pointing to Facebook.com. Right now I am opening it inside a window but want to open it inside a frame.
Is there any way to open Facebook page in IFrame?
Facebook, as most serious sites explicitly disallow this in order to prevent clickjacking.
One of the ways Facebook do this is by sending the 'X-frame-options:deny' header, which instructs your browser to not display the page inside an iframe.
Are you talking about a facebook page within your own website?
If so;
<iframe src="http://www.facebook.com"></iframe>
If not could you provide more information.
Update
See below comment. It seems Facebook blocks it's pages from being includes in iframes.

Check if Facebook app is in an iframe tab

I need my application to redirect to the site with the iframe tab (https://www.facebook.com/pages/namepage...idapp) when someone enters the app (https://apps.facebook.com/idapp)
How can I check if the app is open in an iframe tab?
The a page parameter in the signed_request will be present when the app is loaded via a page tab app, and won't be present otherwise.
Use this to determine if the app should render as a canvas app or a page tab app
Set up the canvas page URL in your app settings, and when that URL is called „redirect” the user via JavaScript, top.location.href = "//facebook.com/yourpageid/…"

How to share links to different pages on iframe?

I have an iframe tab which holds php page with various links inside (like "News", "Photos" etc.). Is it possible to generate a facebook link which leads directly to certain link inside the iframe? By facebook link I mean link that will keep you on facebook, open your iframe tab and view certain page on that iframe. The thing is that all I can do now is to link only to my iframe tab which has address like http://www.facebook.com/mypage/app_someid. Then I will land on my default page tab url. But I want to land on different one. Any tips on this one?
Passing an app_data parameter to the tab URL is passed back to your application as part of the signed_request parameter in FB's post call to include your content. Use that parameter after de-signing it to then decide what to show and what not to.
Your URLs will become like:
http://www.facebook.com/mypage/app_someid?app_data=showViewX
http://www.facebook.com/mypage/app_someid?app_data=showViewY
and then in your code:
// Get Signed Request
$app_data = $signed_request['app_data'];
if($app_data === "showViewX") {
// Show one view
} else {
// show others..
}
Currently, the app_data param is not sent if the user just liked the page when he lands on it with an app_data param. The bug on FB has been filed at https://developers.facebook.com/bugs/172963266154996 and we are all hoping for an early resolution.

Sharing an app that is on a facebook fan page

Afternoon,
I have a facebook application that i have added to a facebook fan page, this application has an URL like http://facebook.com/fanPage?sk=app_id. Now i if copy this link and try and share it on the facebook fan page it uses the description/image from the page and not from the application like it want.
Is there any way to change this? The correct meta tags are in place.
Peter
yes there is a way, but not directly. facebook always fetches the meta tags of the top page, as your app runs in an iframe its not fetched.
but you can submit a wallpost (as user or as a fanpage) via the api and give alle information you want. (like image, video, description, title, ....)
see http://www.fbrell.com/fb.ui/feed for an example.
An other variant:
You add a canvas app beside your facebook app. (see the app settings) on this page you add the meta tags for the wallposts, and a javascript which redirects to the fanpage like
top.location.href = 'http://www.facebook.com/mypage?sk=app_id'
when ever you want to share you use the canvas app url. Facebooks greper ignores the javascript redirects but read the meta tags. A user clicking the wallpost is automaticly redirected to the fanpage - tab.

How do you link to a page within a facebook iframe?

For example, I have the application starting at index.php. The user navigates to about.php within the iframe, likes that specific page and shares it. What would the structure of the url look like to take people clicking from their own timeline into that page of my iframe?
Thanks!
This depends, if you are on a FanPage it does not work (directly)
on a App Page its easy. You simpley dont link relative in your iframe, but outside to the facebook page itself, for this to work your Canvas url needs to be a directory.
Then you can link to ie. http://apps.facebook.com/yourcanvas/about.php (dont forget the target _top)
On a FanPage the only way i know is to use beside the tab setting, a canvas app page.
in your share code you set the app page as target (with parameter) and on the app page you set a session variable for the desired target and then redirect back to the fanpage.
on the fanpage you look if you have an target value in your session, if so redirect the user.