views:

32

answers:

1

I have a website which utilizes facebook integration. You can use it independently of FB. However, it also loads in FB through the canvas page. I want to load a different CSS file if the page is being displayed on the canvas page then when it is displayed through going to it directly.

How can i check if the page loaded in the canvas page?

+1  A: 

Check if the fb_sig_iframe_key parameter is in the querystring. PHP would be:

if($_GET['fb_sig_iframe_key']) // Include CSS Here
Matt Williamson
There is no parameter in the $_GET variable like that....
mprog
Well, that's in PHP. What language are you using?
Matt Williamson
I am using php with the javascript library. I dumped the $_GET variable and there was no key by that name
mprog
Anything similar? I am using that in a production website for a large company. And are you sure you're calling print_r($_GET); in the canvas page?
Matt Williamson
uid and session_key
mprog
and access_token and sigbasically the same stuff that is in the $facebook object
mprog
Those shouldn't be in a normal page so if you check for those to be there you will certainly be in the canvas and not a regular page.
Matt Williamson
you are correct... sort of. It doesnt appear on a regular page but it also does not appear on a canvas page on the first time it loads. All subsequent times it does. However, by that time the css will already be cached.
mprog
Are you calling require_frame on the PHP side or the javascript side?
Matt Williamson
no i am not. wouldnt that cause an issue on the regular site?
mprog
Yeah, it would redirect to the fb page. I'm surprised you are getting the user id at all then. You can put an extra parameter in the canvas URL in the facebook settings, e.g. canvas.php?fb=1 and check for that.
Matt Williamson
i suppose that could work. didnt know i could add parameters to the canvas url like that.
mprog
thanks for your help!
mprog
no problem, any time
Matt Williamson
With sessions generated with the new SDK libs there are no fb_sig_XXXX parameters anymore. Check http://developers.facebook.com/docs/authentication/canvas on how to migrate.
perelin