问题
I'm trying to implement a canvas page on facebook. The Canvas tutorial says that I should set the redirect_url to the canvas page:
http://apps.facebook.com/<appName>
However, when I do that, I get error 191. If I set it to the canvas url http://www.<mysite>.com/fbCanvas
instead, then I lose the Facebook interface, since it opens in the "top" window. What's the correct way to implement this functionality? Is this a bug with Facebook?
回答1:
I had the same problem, and I solved it this way:
Open FBUtils.php
and go to line 94, it reads
echo("<script> top.location.href='" . $authorize_url . "'</script>");
replace it by
echo("<script> window.location.href='" . $authorize_url . "'</script>");
and that's all, you won't get off of FB and your app will be inside the iframe!
回答2:
This is not a normal behavior, your canvas page may be doing something to get rid of the Facebook frame, like setting window.top.location with Javascript etc.
回答3:
The redirect_url is used to redirect users after the auth process. You can not use facebook page as redirect destination. The redirect_url must be in same domain as your original canvas page. Then you can redirect the user after the auth process from your domain to the relevant facebook page.
1, The apps.facebook.com/appName running until you redirect user to FB AUTH process page
2, FB AUTH PAGE redirect the user (after the auth process) to http://www.mysite.com (you should implement the Authentication here)
3, You should reidrect the user to apps.facebook.com/appName back
This flow the most flexible, but little bit difficult to handle if you have more than canvas access point (tab, or webpage).
来源:https://stackoverflow.com/questions/7208642/canvas-authorization-error-191