Facebook App Redirect Top Level Frame - facebook

Is it possible to redirect the top level page from within the iframe of a facebook app?
I'm building a facebook application that will appear in a tab with the JS SDK. I've added a normal a tag that links to the facebook page of the company who's responsible for the app (https://www.facebook.com/) but when I click this link i get:
Refused to display 'https://www.facebook.com/Somersby?ref=ts&fref=ts' in a frame because it set 'X-Frame-Options' to 'DENY'.
It seems Facebook is blocking links in my application that redirect outside of the app's domain. Is there a way to redirect to the company page? Is there an API available to do this?

I misunderstood what was happening here. I forgot to add target="_top" to the link, so it was trying to change the source of the iframe, not the top level frame. It seems facebook can't be displayed in an iFrame, which was the source of the error message.

Related

Redirect Facebook App to Facebook Canvas App (Fluid width)

I'm having a mental meltdown with Facebook and the way it handles Apps and Canvas Apps (apps with fluid width).
I can't figure out how to get a Page Tab to link to a fluid app. You can see an example on Coca Cola's fan page.
https://www.facebook.com/cocacola > Coce Zone tab
First it loads normal blank app which reloads to fluid app.
I have looked at the redirect code and it seems to be a form that submits itself after the page is done loading. After a bit of research I figured out that Facebook creates that itself.
My Page App directs to here but console says this:
Refused to display 'https://apps.facebook.com/ford-koeajotalkoot/' in a frame because it set 'X-Frame-Options' to 'DENY'.
In the app settings below the Page Tab there's Page Tab URL. There you must put an url to file with the redirect. It can be as simple file as below:
<script>
top.location.href="https://apps.facebook.com/YOUR_CANVAS_URL/";
</script>
It will then redirect to your app.

Facebook Page Tab/Facebook Canvas App/Fan Page

This all sounds confusing;
I have a Facebook Canvas App with the same name as the Fan Page. I would like to add an iFrame tab to the Fan Page to promote and link to the Canvas App. My question is do I have to create a new app for the iFrame tab, or do I open my app settings for the canvas app and add settings for a page tab as well in there. Facebook don;t seem to have much documentation and they are changing things for app profiles soon, so I want to make sure I keep my fans of the page.
Thanks in advance.
Basically it goes like this.
You have an iFrame app.
The iFrame app has a canvas which is where you load your html for your app from your webserver with whatever language you want (.NET, PHP etc)
Then you can add this iFrame app to your page.
When you go to http://apps.facebook.com/yourappname
You will be shown the app by itself. When you add it to your page and load it via the tab on the menu of your page it will show you the app within the space on your page (an iframe).
You can use code to detect whether you are on a page or not to display different things.

My App from Page Tab wont load it goes to http://www.facebook.com/common/invalid_request.php#

My Facebook App , on my Canvas loads properly. Both http and https AKA SSL. I then added the app to my Page as a tab. But when I click on the tab, All I get is a Facebook Logo Picture, when I follow the link i.e. Click on the Facebook logo link it brings me to https://www.facebook.com/common/invalid_request.php
I though it might be that the Canvas width size is like 720px, and I lowered my sites width to 520px, the size of pages.
A person in Augest had the same question:
Facebook Application Error In Page
I programmed a Facebook app, and i need to put in a Facebook page.
The application works great outside the Facebook page (standalone).
But when I try to access the application through the page's tab, Facebook's Logo (which linked to http://www.facebook.com/common/invalid_request.php#) appears instead of the app.
What could be the reason to this problem?
A Facebook app can have a different page tab URL configured which should be loaded when the App is loaded on a Page tab - is this set for your app? If so, it may not be set to the URL you were expecting (i.e it's not the same URL as your normal canvas app)
Also, when a page is loaded on a tab, a POST request is sent to your server with a signed_request callback, so your server or code may be expecting only a GET request.
Check these docs for more info:
https://developers.facebook.com/docs/appsonfacebook/pagetabs/ - note that the screenshots on this are currently out of date, i'll see if we can get them updated this week
https://developers.facebook.com/docs/authentication/signed_request/ shows the method to decode the info which is passed to your app on a page-tab load

FacebookSDK-5.0.25.0 for a Iframe Canvas App, after autherization user is redirected to canvas page

I am working on web application with .net 3.5 using C# facebook SDK. Loading page inside Page Tab iframe with some information, and input button, on click of button i am doing auth.Authorize() with some permissions, FB Permission window opens fine, but once user click on allow button it is redirecting to application canvas page instead of Page tab.
Is there anything i am missing?
Regards
Imran
Answer is to set auth.ReturnUrlPath which will bring user back to selected tab in facebook page. If your application is being added to multiple pages, then you can find out current pageid from "signed request" and set correct ReturnUrlPath, and attach ?sk=app_YOUR_APP_ID as querystring to ReturnUrlPath so current tab will be selected. your return path will look something similar to : http://www.facebook.com/profile.php?id=YOUR_PAGE_ID&sk=app_YOUR_APP_ID (make sure you handle both http and https)
This worked for me, hopefully will work for someone too.
-Ims
Facebook C# SDK doesnt support tabs.
Only canvas apps are supported.

creating a tab page for a FB Pages app

I have created a FB Pages app and am trying to figure out why my tab html is not displaying.
when I go directly to my example.com/tab url that I have set in the facebook app settings I can see the expected HTML. When I go to my app tab on a sample facebook page I can see the request come for example.com/tab on my server as expected but nothing is displayed in the facebook page tab!
all I have is a simple
<div>hello world!</div>
and it doesn't display in the tab. Any idea why this is happening?
It's possible you don't have a valid SSL cert installed on your server. Or facebook may be caching an old URL. Check the URL it's trying to load in the iFrame to ensure Facebook is using the correct one.