2

I know there is a way to redirect the page using javascript in the iframe of the canvas application to an external url.But is there any other way so that user directly gets redirected to the external url as soon as they authorizes the application.

i know it is possible because a famous app klout in Facebook does it.

http://apps.facebook.com/klout__/

redirects to

http://klout.com/ automatically as soon as the user

Remember i got an invitation request from my Facebook friend.when i clicked the invitation notification and when i authorized the application it redirected to a external url.Any idea how this has been done? And i think this wont be encouraged in Facebook policies either?

bkaid
  • 51,465
  • 22
  • 112
  • 128
Saru Nathan
  • 140
  • 2
  • 11

1 Answers1

2

Facebook want to make sure that the servers it interacts with are of the same domain that is set up in the app settings.

In the klout example you gave what they did was to add an App Domain which is done in the app settings, but there's a limitation to what domains you can add there. For example if your site url in the settings is set to "www.example.com" then you can add "examlpe.com" or "sub.example.com" to the app domains. But if you try to add "www.example2.com" you'll get:

Error

example2.com must be derived from your Site URL or your Mobile Web URL.


Edit

I'm sorry, I did not understand you correctly.

If you want to simply redirect the user to your url in the main window then you can use javascript like this:

top.location.href = "http://www.example.com";

What I was referring to before is the ability to have "www.example.com/" as the site url (in the settings) and still use "sub.example.com" with redirect_uri and such.


2nd Edit

Forgot to mention this: In the Facebook Platform Policies it states that:

13 . The primary purpose of your Canvas or Page Tab app on Facebook must not be to simply redirect users out of the Facebook experience and onto an external site

And so you should not redirect the users out of facebook.

Nitzan Tomer
  • 155,636
  • 47
  • 315
  • 299
  • actually what i asked was how to redirect the application to my external url? when i have enabled my iframe canvas application in my settings tab? like how klout does? i dont get what is that you are comeing to say? could you explain it? – Saru Nathan Apr 19 '12 at 16:54
  • Sorry, completely misunderstood you there.. I edited my answer, hopefully this time I understood you. – Nitzan Tomer Apr 19 '12 at 17:06
  • Thats what i actually expected.And thanks for your answer.Does this legal when comes to facebook policies?else is there any option i could redirect the page by changing the settings in my application? – Saru Nathan Apr 19 '12 at 17:19
  • 1
    You're right, I forgot to mention that part... Edited my answer again, so that others will see it if they come across this. – Nitzan Tomer Apr 19 '12 at 17:25
  • Then how does klout app redirects its application using its external url? Is that violating the facebook app policies? or you have any idea how they do it? they too have a canvas url? That one is confusing me. – Saru Nathan Apr 19 '12 at 17:28
  • 1
    They are doing it differently, they just specified their url as the "redirect_url" instead of the canvas url (apps.facebook.com/klout__). As for the privacy issue, I think that it's a violation of it, I've seen other apps that do it, and my guess is that facebook might block those apps if the choose to, basically it's risking it (I think), I have no clue how much, if at all, facebook actually enforces that. – Nitzan Tomer Apr 19 '12 at 17:38
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/10286/discussion-between-saru-nathan-and-nitzan-tomer) – Saru Nathan Apr 19 '12 at 17:43