Help needed for Facebook Canvas integration

Started by dwd2000, March 30, 2015, 03:16:12 AM

Previous topic - Next topic

dwd2000

SMF 2.0.9

I'm trying to have my arcade site fully integrated as a "Canvas" page on Facebook, just like the other games many people play on Facebook.
This is very different from just using Facebook login, etc., and the mod available now isn't for the new version needed by April 2015. (no updates planned for the mod either)
I already have my SSL and app setup.

There are 2 ways I could do it:

1) - Facebook SDK for JavaScript   https://developers.facebook.com/docs/javascript/quickstart/v2.3

2) - Facebook SDK for PHP  https://developers.facebook.com/docs/php/gettingstarted/4.0.0

The javascript looks easier, but can't figure out where to put it.
QuoteYou should insert it directly after the opening <body> tag on each page you want to load it:
I tried several ways, but got syntax errors, probably because <body> is within an "echo"

Is there a way to make a separate page and have SMF refer to it? (either method)

Any help would be greatly appreciated.
30 years ago I was young and foolish.
Now I'm just young.

DAMMIT JIM...I'M A TWEAKER...NOT A CODER!!!

Dave's Games

margarett

I'm not sure if we can completely assist you with that, but we can try :)

You can have a separate page and get SMF to work it out by using SSI.php, then adding your content in it. Refer to ssi_examples.php that you have in your forum root for an idea on how to do it.

About the syntax errors, you should probably add that to Arcade.template.php (or index.template.php, conditioned by action == arcade, probably this last case would be better)
You should just need to echo your javascript after <body>, being careful to escape all single quotes with a backslash. If you use a good editor like Notepad++, the color of the text should tell you immediately if your are messing things up ;)
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

dwd2000

#2
Just a note:

I'm not ignoring anyone, just been busy. :(

I'm learning a lot with your "SSI" advice. :)
Looks like I might be able to design my own separate site, using SMF as a type of "Operating System".
(calling functions and actions as needed)

Syntax errors:
Yes, I have used Notepad++ for years, but didn't really understand the colour coding for some things.
Turned out, escaping the single quotes did the trick. :)

I'd like to keep this topic open, so that others may learn as I/we figure things out.

If interested, I've set up a test page:

https://www.daves-games.com/HomePageSample.php
30 years ago I was young and foolish.
Now I'm just young.

DAMMIT JIM...I'M A TWEAKER...NOT A CODER!!!

Dave's Games

margarett

Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

dwd2000

I need a little help now with the JavaScript SDK.
I need to know how to transfer the info Facebook allows me to get, (name, e-mail, public profile, and friends) into the SMF database as a new member.
This is a quote from the Facebook tutorial, which sadly, leaves the actual "How to" out.
Quote
Can I use the Login Button with server-side registration code?

You can, however you will still need to use the JavaScript SDK partially. Once the login process started by clicking on the button is done, the SDK will have access to an authResponse object using FB.getLoginStatus(). You can use this function to pass the response object to your server-side code to complete any registration that exists there.

Below, is a sample of the code Facebook provided for a test page. It works nicely if you want to say "Hi "user". :)
The "not authorized" part of the code is what I'm thinking could gather the info and transfer it to the database.
(the code is asking the user to log into the app)


  function statusChangeCallback(response) {
    console.log('statusChangeCallback');
    console.log(response);
    // The response object is returned with a status field that lets the
    // app know the current login status of the person.
    // Full docs on the response object can be found in the documentation
    // for FB.getLoginStatus().
    if (response.status === 'connected') {
      // Logged into your app and Facebook.
      testAPI();
    } else if (response.status === 'not_authorized') {
      // The person is logged into Facebook, but not your app.
      document.getElementById('status').innerHTML = 'Please log ' +
        'into this app.';
    } else {
      // The person is not logged into Facebook, so we're not sure if
      // they are logged into this app or not.
      document.getElementById('status').innerHTML = 'Please log ' +
        'into Facebook.';
    }
  }


I've gone through the SAFacebook mod, but it's way too complicated for me, plus, there's too many bells and whistles for my needs, plus, there's guarantee of an updated version for the new Facebook version. (2.x)
I'm just looking for a simple way.
30 years ago I was young and foolish.
Now I'm just young.

DAMMIT JIM...I'M A TWEAKER...NOT A CODER!!!

Dave's Games

Advertisement: