2
votes

I am developing a Canvas application in Facebook in php. When the user allows the permission it's redirected to my site, as the say in the help page https://developers.facebook.com/docs/reference/dialogs/oauth/.

But I don't want to be redirected to my site, I want to be redirected to the facebook page which contains my site in an iframe. How can I do this? It should be quite straightway.

If the user clicks "Allow", they will be directed to
http://www.example.com/response#access_token=...&  expires_in=3600
If the user clicks "Don't Allow", they will be directed to
http://www.example.com/response?
  error=access_denied&
  error_description=The+user+denied+your+request.

I don't want to go to example.com but to facebook.com/app/ID_APP which contains example.com

EDIT:

after Floyd Wilburn's answer, I tried to put my app page but it doesn't work. It gives me an error. While the right URL looks like this

https://www.facebook.com/dialog/permissions.request?app_id=53434949999999&display/=page&next=http%3A%2F%2Fwww.example.com%2Fapp%2F%3Fnext_url%3Dhttp%253A%252F%252Fapps.facebook.com%28403a2224870942%252F&response_type=code&fbconnect=1&perms=email%2Cread_stream

(we can see the my site url example.com encoded with a parameter 'next_url' to which the user will b redirected from my site page)

the URL of the wrong way looks like this (Just changin my site to my facebook app url )

https://www.facebook.com/dialog/oauth?client_id=185340534870942&redirect_uri=http%3A%2F%2Fapps.facebook.com%2F534349499999s992%2Fhello.php

So my solution is what I commented. The user gets to my site and is redirected to the facebook app URL.

Anyone can guess why Floyd Wilburn's solution doesn't work for me?

Thanks

1
Looking at your url above, I think my answer may not have been clear -- the 'yourapp' part is not the app_id, it is the canvas page name (App Namespace setting). - Floyd Wilburn
The problem with the redirect that you set "apps.facebook.com/pagename/hello.php" is that you are missing the reference to your app, which is usually http://apps.facebook.com/pages/yourpage/?sk=app_[your app id] - that will load whatever you have put as your canvas url. Canvas url is the directory on your own site (not on fb). so if I host it in /var/www/html/myapp, I will expect the returend authe'd user to come through myapp/index.php. - Anna Billstrom

1 Answers

2
votes

Just set the redirect_uri parameter to point at http://apps.facebook.com/yourapp/somepage and it will go there instead.