Andree
Andree

Reputation: 3103

Facebook application, how to check if inside Facebook canvas / standalone using PHP?

I want to develop a Facebook connect application that can operate both inside a Facebook canvas or standalone.

Can I check if the user is using Facebook canvas / not using the official Facebook PHP client library?

Thanks, Andree

Upvotes: 5

Views: 2342

Answers (2)

qodeninja
qodeninja

Reputation: 11266

Check the HTTP_REFERER header. If the referrer is "apps.facebook.com", then its loading in Facebook canvas.

Upvotes: 0

Eric
Eric

Reputation: 54

In case of a Canvas page, Facebook will pass the client's IP address in an additional HTTP header called X-FB-USER-REMOTE-ADDR.

http://wiki.developers.facebook.com/index.php/Your_callback_page_and_you

If it's set, you're on Facebook.

A hacker could also send this header, and that could result in unexpected behaviour from your app when outside Facebook.

Upvotes: 3

Related Questions