2

Here is my question: Im trying to create a Facebook Canvas Application with PHP sdk 4.0 and im lost in all the confusing documentations... I don't understand how the login process is working with multiple pages application. Can someone help me please?

I put this code on the landing page of the app and that works fine:

FacebookSession::setDefaultApplication( 'app_id', 'app_secret' );
$helper = new FacebookCanvasLoginHelper();
try {
    $session = $helper->getSession();
} catch (FacebookRequestException $ex) {}

the question is: what should i do on the second page? _Write the same code? _Save the Facebook session in $_SESSION in order to use it on the other pages? _Save only the token to retreive the session?

I walked the web for 2 days to find the answer with no result.. I found Facebook documentation is not very clear

Thx to you a lot! ;)

StefNoMan
  • 23
  • 3
  • why not go the easy road and use the JavaScript SDK? it´s so much easier, and the usability is much better. No page refresh needed when the token is not valid anymore, and no redirect needed for the login process. just a nice popup with FB.login. also, no PHP needed, which means no server with PHP5.4+. and you never need to save the token and stuff, because the SDK does everything for you. – andyrandy Oct 04 '14 at 18:17
  • thx for your answer. I'm going to look at this but the problem is the same: how do i implement sessionning? which function(s) should i call on each page? – StefNoMan Oct 17 '14 at 09:10

1 Answers1

0

You need to set the session / access_token and save it to a PHP Session, e.g.

$_SESSION['access_token'] = $session->getToken();

This tutorial I wrote will help you out.

Niraj Shah
  • 15,087
  • 3
  • 41
  • 60