T
T
tincap2016-02-03 22:51:51
Facebook
tincap, 2016-02-03 22:51:51

What is this $session in Facebook Api?

The facebook api documentation says how to make a request

$request = new FacebookRequest(
  $session,
  'GET',
  '/{user-id-a}/friends/{user-id-b}'
);

But what is this $session variable?
access_token received

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Burov, 2016-02-03
@tincap

https://developers.facebook.com/docs/php/FacebookS...

use Facebook\FacebookSession;

FacebookSession::setDefaultApplication('app-id', 'app-secret');

// If you already have a valid access token:
$session = new FacebookSession('access-token');

// If you're making app-level requests:
$session = FacebookSession::newAppSession();

// To validate the session:
try {
  $session->validate();
} catch (FacebookRequestException $ex) {
  // Session not valid, Graph API returned an exception with the reason.
  echo $ex->getMessage();
} catch (\Exception $ex) {
  // Graph API returned info, but it may mismatch the current app or have expired.
  echo $ex->getMessage();
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question