Skip to content

Instantly share code, notes, and snippets.

@xeoncross
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xeoncross/9560822 to your computer and use it in GitHub Desktop.
Save xeoncross/9560822 to your computer and use it in GitHub Desktop.
Things I'm learning about writing a facebook canvas application
  • You must setup an SSL cert to make your life easy.

  • Create a fake app.localhost.loc virtual host or something by editing your /etc/hosts or windows hosts file and pointing that domain to 127.0.0.1 and then editing your nginx or Apache config.

  • For FB login You can't do a header() redirect because of X-Frame-Options. Use Javascript instead:

      <html><script>top.location.href = "loginUrl";</script></html>
    
  • All requests that should be HTTP GET will become POST requests.

  • Signed Request

    • You can parse it with $signed_request = $facebook->getSignedRequest();
    • if you are not using the FB SDK you need this.
    • If a user visits your app without signing/authorizing your app in you will still have a signed_request variable which is nice.
        [signed_request_object] => Array
        (
            [algorithm] => HMAC-SHA256
            [issued_at] => 1394849666
            [user] => Array
                (
                    [country] => us
                    [locale] => en_US
                    [age] => Array
                        (
                            [min] => 21
                        )

                )

        )

        Logged in User:

        [signed_request_object] => Array
        (
            [algorithm] => HMAC-SHA256
            [expires] => 1314856000
            [issued_at] => 1314850255
            [oauth_token] => CAAJKO... ...ogZDZD
            [user] => Array
                (
                    [country] => us
                    [locale] => en_US
                    [age] => Array
                        (
                            [min] => 21
                        )

                )

            [user_id] => 12345
        )

Your friends and their friends:

SELECT uid, name, pic_square FROM user WHERE uid = me() OR uid IN (SELECT uid2 FROM friend WHERE uid1 = me())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment