This document refers to an outdated version of PHP SDK. Please use the latest version.
PHP SDK Version

FacebookCanvasLoginHelper

A helper class for getting a FacebookSession in a Canvas app

Usage

If your app is loaded through Canvas, Facebook sends a POST request with a signed request. This helper class will handle processing and validating that information with Facebook, and returns a FacebookSession.

Example:

// add `use Facebook\FacebookCanvasLoginHelper;`
$helper = new FacebookCanvasLoginHelper();
try {
  $session = $helper->getSession();
} catch (FacebookRequestException $ex) {
    // When Facebook returns an error
} catch (\Exception $ex) {
    // When validation fails or other local issues  
}
if ($session) {
  // Logged in.
}

Instance Methods

getSession

getSession()
Processes the POST request from Facebook, if present. Returns a FacebookSession or null.