3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * Copyright 2014 Facebook, Inc. * * You are hereby granted a non-exclusive, worldwide, royalty-free license to * use, copy, modify, and distribute this software in source code or binary * form for use in connection with the web services and APIs provided by * Facebook. * * As with any software that integrates with the Facebook platform, your use * of this software is subject to the Facebook Developer Principles and * Policies [http://developers.facebook.com/policy/]. This copyright notice * shall be included in all copies or substantial portions of the software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. * */ namespace Facebook; /** * Class FacebookSession * @package Facebook * @author Fosco Marotto <fjm@fb.com> * @author David Poll <depoll@fb.com> */ class FacebookSession { /** * @var string */ private static $defaultAppId; /** * @var string */ private static $defaultAppSecret; /** * @var string The token string for the session */ private $token; /** * @var array */ private $signedRequestData; /** * When creating a Session from an access_token, use: * var $session = new FacebookSession($accessToken); * This will validate the token and provide a Session object ready for use. * It will throw a SessionException in case of error. * * @param string $accessToken * @param array $parsedSignedRequest The signed request data if available */ public function __construct($accessToken, $parsedSignedRequest = null) { $this->token = $accessToken; $this->signedRequestData = $parsedSignedRequest; } /** * Returns the access token * * @return string */ public function getToken() { return $this->token; } /** * Returns the signed request data from the sessions creation * * @return null|array */ public function getSignedRequestData() { return $this->signedRequestData; } /** * Returns a property from the signed request data if available * * @param string $keyname * * @return null|mixed */ public function getSignedRequestProperty($keyname) { if (isset($this->signedRequestData[$keyname])) { return $this->signedRequestData[$keyname]; } return null; } /** * Returns user_id from signed request data if available * * @return null|string */ public function getUserId() { return $this->getSignedRequestProperty('user_id'); } /** * getSessionInfo - Makes a request to /debug_token with the appropriate * arguments to get debug information about the sessions token. * * @param string|null $appId * @param string|null $appSecret * * @return GraphSessionInfo */ public function getSessionInfo($appId = null, $appSecret = null) { $targetAppId = static::_getTargetAppId($appId); $targetAppSecret = static::_getTargetAppSecret($appSecret); return (new FacebookRequest( static::newAppSession($targetAppId, $targetAppSecret), 'GET', '/debug_token', array( 'input_token' => $this->getToken(), ) ))->execute()->getGraphObject(GraphSessionInfo::className()); } /** * getLongLivedSession - Returns a new Facebook session resulting from * extending a short-lived access token. If this session is not * short-lived, returns $this. * * @param string|null $appId * @param string|null $appSecret * * @return FacebookSession */ public function getLongLivedSession($appId = null, $appSecret = null) { $targetAppId = static::_getTargetAppId($appId); $targetAppSecret = static::_getTargetAppSecret($appSecret); $params = array( 'client_id' => $targetAppId, 'client_secret' => $targetAppSecret, 'grant_type' => 'fb_exchange_token', 'fb_exchange_token' => $this->getToken() ); // The response for this endpoint is not JSON, so it must be handled // differently, not as a GraphObject. $response = (new FacebookRequest( self::newAppSession($targetAppId, $targetAppSecret), 'GET', '/oauth/access_token', $params ))->execute()->getResponse(); if ($response) { return new FacebookSession($response['access_token']); } else { return $this; } } /** * getExchangeToken - Returns an exchange token string which can be sent * back to clients and exchanged for a device-linked access token. * * @param string|null $appId * @param string|null $appSecret * * @return string */ public function getExchangeToken($appId = null, $appSecret = null) { $targetAppId = static::_getTargetAppId($appId); $targetAppSecret = static::_getTargetAppSecret($appSecret); // Redirect URI is being removed as a requirement. Passing an empty string. $params = array( 'client_id' => $targetAppId, 'access_token' => $this->getToken(), 'client_secret' => $targetAppSecret, 'redirect_uri' => '' ); $response = (new FacebookRequest( self::newAppSession($targetAppId, $targetAppSecret), 'GET', '/oauth/client_code', $params ))->execute()->getGraphObject(); return $response->getProperty('code'); } /** * validate - Ensures the current session is valid, throwing an exception if * not. Fetches token info from Facebook. * * @param string|null $appId Application ID to use * @param string|null $appSecret App secret value to use * * @return boolean */ public function validate($appId = null, $appSecret = null) { $targetAppId = static::_getTargetAppId($appId); $targetAppSecret = static::_getTargetAppSecret($appSecret); $info = $this->getSessionInfo($targetAppId, $targetAppSecret); return self::validateSessionInfo($info, $targetAppId); } /** * validateTokenInfo - Ensures the provided GraphSessionInfo object is valid, * throwing an exception if not. Ensures the appId matches, * that the token is valid and has not expired. * * @param GraphSessionInfo $tokenInfo * @param string|null $appId Application ID to use * * @return boolean * * @throws FacebookSDKException */ public static function validateSessionInfo(GraphSessionInfo $tokenInfo, $appId = null) { $targetAppId = static::_getTargetAppId($appId); if ($tokenInfo->getAppId() !== $targetAppId || !$tokenInfo->isValid() || $tokenInfo->getExpiresAt() === null || $tokenInfo->getExpiresAt()->getTimestamp() < time()) { throw new FacebookSDKException( 'Session has expired, or is not valid for this app.', 601 ); } return true; } /** * newSessionFromSignedRequest - Returns a FacebookSession for a * given signed request. * * @param string $signedRequest * @param string $state * * @return FacebookSession */ public static function newSessionFromSignedRequest($signedRequest, $state = null) { $parsedRequest = self::parseSignedRequest($signedRequest, $state); if (isset($parsedRequest['code']) && !isset($parsedRequest['oauth_token'])) { return self::newSessionAfterValidation($parsedRequest); } return new FacebookSession($parsedRequest['oauth_token'], $parsedRequest); } /** * newSessionAfterValidation - Returns a FacebookSession for a * validated & parsed signed request. * * @param array $parsedSignedRequest * * @return FacebookSession * * @throws FacebookRequestException */ private static function newSessionAfterValidation($parsedSignedRequest) { $params = array( 'client_id' => self::$defaultAppId, 'redirect_uri' => '', 'client_secret' => self::$defaultAppSecret, 'code' => $parsedSignedRequest['code'] ); $response = (new FacebookRequest( self::newAppSession( self::$defaultAppId, self::$defaultAppSecret), 'GET', '/oauth/access_token', $params ))->execute()->getResponse(); if (isset($response['access_token'])) { return new FacebookSession( $response['access_token'], $parsedSignedRequest ); } throw FacebookRequestException::create( json_encode($parsedSignedRequest), $parsedSignedRequest, 401 ); } /** * Parses a signed request. * * @param string $signedRequest * @param string $state * * @return array * * @throws FacebookSDKException */ private static function parseSignedRequest($signedRequest, $state) { if (strpos($signedRequest, '.') !== false) { list($encodedSig, $encodedData) = explode('.', $signedRequest, 2); $sig = self::_base64UrlDecode($encodedSig); $data = json_decode(self::_base64UrlDecode($encodedData), true); if (isset($data['algorithm']) && $data['algorithm'] === 'HMAC-SHA256') { $expectedSig = hash_hmac( 'sha256', $encodedData, self::$defaultAppSecret, true ); if (strlen($sig) !== strlen($expectedSig)) { throw new FacebookSDKException( 'Invalid signature on signed request.', 602 ); } $validate = 0; for ($i = 0; $i < strlen($sig); $i++) { $validate |= ord($expectedSig[$i]) ^ ord($sig[$i]); } if ($validate !== 0) { throw new FacebookSDKException( 'Invalid signature on signed request.', 602 ); } if (!isset($data['oauth_token']) && !isset($data['code'])) { throw new FacebookSDKException( 'Invalid signed request, missing OAuth data.', 603 ); } if ($state && (!isset($data['state']) || $data['state'] != $state)) { throw new FacebookSDKException( 'Signed request did not pass CSRF validation.', 604 ); } return $data; } else { throw new FacebookSDKException( 'Invalid signed request, using wrong algorithm.', 605 ); } } else { throw new FacebookSDKException( 'Malformed signed request.', 606 ); } } /** * newAppSession - Returns a FacebookSession configured with a token for the * application which can be used for publishing and requesting app-level * information. * * @param string|null $appId Application ID to use * @param string|null $appSecret App secret value to use * * @return FacebookSession */ public static function newAppSession($appId = null, $appSecret = null) { $targetAppId = static::_getTargetAppId($appId); $targetAppSecret = static::_getTargetAppSecret($appSecret); return new FacebookSession( $targetAppId . '|' . $targetAppSecret ); } /** * setDefaultApplication - Will set the static default appId and appSecret * to be used for API requests. * * @param string $appId Application ID to use by default * @param string $appSecret App secret value to use by default */ public static function setDefaultApplication($appId, $appSecret) { self::$defaultAppId = $appId; self::$defaultAppSecret = $appSecret; } /** * _getTargetAppId - Will return either the provided app Id or the default, * throwing if neither are populated. * * @param string $appId * * @return string * * @throws FacebookSDKException */ public static function _getTargetAppId($appId = null) { $target = ($appId ?: self::$defaultAppId); if (!$target) { throw new FacebookSDKException( 'You must provide or set a default application id.', 700 ); } return $target; } /** * _getTargetAppSecret - Will return either the provided app secret or the * default, throwing if neither are populated. * * @param string $appSecret * * @return string * * @throws FacebookSDKException */ public static function _getTargetAppSecret($appSecret = null) { $target = ($appSecret ?: self::$defaultAppSecret); if (!$target) { throw new FacebookSDKException( 'You must provide or set a default application secret.', 701 ); } return $target; } /** * Base64 decoding which replaces characters: * + instead of - * / instead of _ * @link http://en.wikipedia.org/wiki/Base64#URL_applications * * @param string $input base64 url encoded input * * @return string The decoded string */ public static function _base64UrlDecode($input) { return base64_decode(strtr($input, '-_', '+/')); } }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MiJ8K
function name:  (null)
number of ops:  1
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  446     0  E > > RETURN                                                   1

Class Facebook\FacebookSession:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MiJ8K
function name:  __construct
number of ops:  7
compiled vars:  !0 = $accessToken, !1 = $parsedSignedRequest
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   64     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      null
   66     2        ASSIGN_OBJ                                               'token'
          3        OP_DATA                                                  !0
   67     4        ASSIGN_OBJ                                               'signedRequestData'
          5        OP_DATA                                                  !1
   68     6      > RETURN                                                   null

End of function __construct

Function gettoken:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MiJ8K
function name:  getToken
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   77     0  E >   FETCH_OBJ_R                                      ~0      'token'
          1      > RETURN                                                   ~0
   78     2*     > RETURN                                                   null

End of function gettoken

Function getsignedrequestdata:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MiJ8K
function name:  getSignedRequestData
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   87     0  E >   FETCH_OBJ_R                                      ~0      'signedRequestData'
          1      > RETURN                                                   ~0
   88     2*     > RETURN                                                   null

End of function getsignedrequestdata

Function getsignedrequestproperty:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 7
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MiJ8K
function name:  getSignedRequestProperty
number of ops:  9
compiled vars:  !0 = $keyname
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   97     0  E >   RECV                                             !0      
   99     1        FETCH_OBJ_IS                                     ~1      'signedRequestData'
          2        ISSET_ISEMPTY_DIM_OBJ                         0          ~1, !0
          3      > JMPZ                                                     ~2, ->7
  100     4    >   FETCH_OBJ_R                                      ~3      'signedRequestData'
          5        FETCH_DIM_R                                      ~4      ~3, !0
          6      > RETURN                                                   ~4
  102     7    > > RETURN                                                   null
  103     8*     > RETURN                                                   null

End of function getsignedrequestproperty

Function getuserid:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MiJ8K
function name:  getUserId
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  112     0  E >   INIT_METHOD_CALL                                         'getSignedRequestProperty'
          1        SEND_VAL_EX                                              'user_id'
          2        DO_FCALL                                      0  $0      
          3      > RETURN                                                   $0
  113     4*     > RETURN                                                   null

End of function getuserid

Function getsessioninfo:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MiJ8K
function name:  getSessionInfo
number of ops:  32
compiled vars:  !0 = $appId, !1 = $appSecret, !2 = $targetAppId, !3 = $targetAppSecret
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  124     0  E >   RECV_INIT                                        !0      null
          1        RECV_INIT                                        !1      null
  126     2        INIT_STATIC_METHOD_CALL                                  '_getTargetAppId'
          3        SEND_VAR_EX                                              !0
          4        DO_FCALL                                      0  $4      
          5        ASSIGN                                                   !2, $4
  127     6        INIT_STATIC_METHOD_CALL                                  '_getTargetAppSecret'
          7        SEND_VAR_EX                                              !1
          8        DO_FCALL                                      0  $6      
          9        ASSIGN                                                   !3, $6
  128    10        NEW                                              $8      'Facebook%5CFacebookRequest'
  129    11        INIT_STATIC_METHOD_CALL                                  'newAppSession'
         12        SEND_VAR_EX                                              !2
         13        SEND_VAR_EX                                              !3
         14        DO_FCALL                                      0  $9      
         15        SEND_VAR_NO_REF_EX                                       $9
  130    16        SEND_VAL_EX                                              'GET'
  131    17        SEND_VAL_EX                                              '%2Fdebug_token'
  133    18        INIT_METHOD_CALL                                         'getToken'
         19        DO_FCALL                                      0  $10     
         20        INIT_ARRAY                                       ~11     $10, 'input_token'
         21        SEND_VAL_EX                                              ~11
         22        DO_FCALL                                      0          
  135    23        INIT_METHOD_CALL                                         $8, 'execute'
         24        DO_FCALL                                      0  $13     
         25        INIT_METHOD_CALL                                         $13, 'getGraphObject'
         26        INIT_STATIC_METHOD_CALL                                  'Facebook%5CGraphSessionInfo', 'className'
         27        DO_FCALL                                      0  $14     
         28        SEND_VAR_NO_REF_EX                                       $14
         29        DO_FCALL                                      0  $15     
         30      > RETURN                                                   $15
  136    31*     > RETURN                                                   null

End of function getsessioninfo

Function getlonglivedsession:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 33, Position 2 = 40
Branch analysis from position: 33
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 40
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MiJ8K
function name:  getLongLivedSession
number of ops:  43
compiled vars:  !0 = $appId, !1 = $appSecret, !2 = $targetAppId, !3 = $targetAppSecret, !4 = $params, !5 = $response
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  148     0  E >   RECV_INIT                                        !0      null
          1        RECV_INIT                                        !1      null
  150     2        INIT_STATIC_METHOD_CALL                                  '_getTargetAppId'
          3        SEND_VAR_EX                                              !0
          4        DO_FCALL                                      0  $6      
          5        ASSIGN                                                   !2, $6
  151     6        INIT_STATIC_METHOD_CALL                                  '_getTargetAppSecret'
          7        SEND_VAR_EX                                              !1
          8        DO_FCALL                                      0  $8      
          9        ASSIGN                                                   !3, $8
  153    10        INIT_ARRAY                                       ~10     !2, 'client_id'
  154    11        ADD_ARRAY_ELEMENT                                ~10     !3, 'client_secret'
  155    12        ADD_ARRAY_ELEMENT                                ~10     'fb_exchange_token', 'grant_type'
  156    13        INIT_METHOD_CALL                                         'getToken'
         14        DO_FCALL                                      0  $11     
         15        ADD_ARRAY_ELEMENT                                ~10     $11, 'fb_exchange_token'
  152    16        ASSIGN                                                   !4, ~10
  160    17        NEW                                              $13     'Facebook%5CFacebookRequest'
  161    18        INIT_STATIC_METHOD_CALL                                  'newAppSession'
         19        SEND_VAR_EX                                              !2
         20        SEND_VAR_EX                                              !3
         21        DO_FCALL                                      0  $14     
         22        SEND_VAR_NO_REF_EX                                       $14
  162    23        SEND_VAL_EX                                              'GET'
  163    24        SEND_VAL_EX                                              '%2Foauth%2Faccess_token'
  161    25        SEND_VAR_EX                                              !4
         26        DO_FCALL                                      0          
  165    27        INIT_METHOD_CALL                                         $13, 'execute'
         28        DO_FCALL                                      0  $16     
         29        INIT_METHOD_CALL                                         $16, 'getResponse'
         30        DO_FCALL                                      0  $17     
  160    31        ASSIGN                                                   !5, $17
  166    32      > JMPZ                                                     !5, ->40
  167    33    >   NEW                                              $19     'Facebook%5CFacebookSession'
         34        CHECK_FUNC_ARG                                           
         35        FETCH_DIM_FUNC_ARG                               $20     !5, 'access_token'
         36        SEND_FUNC_ARG                                            $20
         37        DO_FCALL                                      0          
         38      > RETURN                                                   $19
         39*       JMP                                                      ->42
  169    40    >   FETCH_THIS                                       ~22     
         41      > RETURN                                                   ~22
  171    42*     > RETURN                                                   null

End of function getlonglivedsession

Function getexchangetoken:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MiJ8K
function name:  getExchangeToken
number of ops:  37
compiled vars:  !0 = $appId, !1 = $appSecret, !2 = $targetAppId, !3 = $targetAppSecret, !4 = $params, !5 = $response
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  182     0  E >   RECV_INIT                                        !0      null
          1        RECV_INIT                                        !1      null
  184     2        INIT_STATIC_METHOD_CALL                                  '_getTargetAppId'
          3        SEND_VAR_EX                                              !0
          4        DO_FCALL                                      0  $6      
          5        ASSIGN                                                   !2, $6
  185     6        INIT_STATIC_METHOD_CALL                                  '_getTargetAppSecret'
          7        SEND_VAR_EX                                              !1
          8        DO_FCALL                                      0  $8      
          9        ASSIGN                                                   !3, $8
  188    10        INIT_ARRAY                                       ~10     !2, 'client_id'
  189    11        INIT_METHOD_CALL                                         'getToken'
         12        DO_FCALL                                      0  $11     
         13        ADD_ARRAY_ELEMENT                                ~10     $11, 'access_token'
  190    14        ADD_ARRAY_ELEMENT                                ~10     !3, 'client_secret'
  191    15        ADD_ARRAY_ELEMENT                                ~10     '', 'redirect_uri'
  187    16        ASSIGN                                                   !4, ~10
  193    17        NEW                                              $13     'Facebook%5CFacebookRequest'
  194    18        INIT_STATIC_METHOD_CALL                                  'newAppSession'
         19        SEND_VAR_EX                                              !2
         20        SEND_VAR_EX                                              !3
         21        DO_FCALL                                      0  $14     
         22        SEND_VAR_NO_REF_EX                                       $14
  195    23        SEND_VAL_EX                                              'GET'
  196    24        SEND_VAL_EX                                              '%2Foauth%2Fclient_code'
  194    25        SEND_VAR_EX                                              !4
         26        DO_FCALL                                      0          
  198    27        INIT_METHOD_CALL                                         $13, 'execute'
         28        DO_FCALL                                      0  $16     
         29        INIT_METHOD_CALL                                         $16, 'getGraphObject'
         30        DO_FCALL                                      0  $17     
  193    31        ASSIGN                                                   !5, $17
  199    32        INIT_METHOD_CALL                                         !5, 'getProperty'
         33        SEND_VAL_EX                                              'code'
         34        DO_FCALL                                      0  $19     
         35      > RETURN                                                   $19
  200    36*     > RETURN                                                   null

End of function getexchangetoken

Function validate:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MiJ8K
function name:  validate
number of ops:  21
compiled vars:  !0 = $appId, !1 = $appSecret, !2 = $targetAppId, !3 = $targetAppSecret, !4 = $info
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  211     0  E >   RECV_INIT                                        !0      null
          1        RECV_INIT                                        !1      null
  213     2        INIT_STATIC_METHOD_CALL                                  '_getTargetAppId'
          3        SEND_VAR_EX                                              !0
          4        DO_FCALL                                      0  $5      
          5        ASSIGN                                                   !2, $5
  214     6        INIT_STATIC_METHOD_CALL                                  '_getTargetAppSecret'
          7        SEND_VAR_EX                                              !1
          8        DO_FCALL                                      0  $7      
          9        ASSIGN                                                   !3, $7
  215    10        INIT_METHOD_CALL                                         'getSessionInfo'
         11        SEND_VAR_EX                                              !2
         12        SEND_VAR_EX                                              !3
         13        DO_FCALL                                      0  $9      
         14        ASSIGN                                                   !4, $9
  216    15        INIT_STATIC_METHOD_CALL                                  'validateSessionInfo'
         16        SEND_VAR_EX                                              !4
         17        SEND_VAR_EX                                              !2
         18        DO_FCALL                                      0  $11     
         19      > RETURN                                                   $11
  217    20*     > RETURN                                                   null

End of function validate

Function validatesessioninfo:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 47) Position 1 = 10, Position 2 = 14
Branch analysis from position: 10
2 jumps found. (Code = 47) Position 1 = 15, Position 2 = 19
Branch analysis from position: 15
2 jumps found. (Code = 47) Position 1 = 20, Position 2 = 28
Branch analysis from position: 20
2 jumps found. (Code = 43) Position 1 = 29, Position 2 = 34
Branch analysis from position: 29
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 34
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 28
Branch analysis from position: 19
Branch analysis from position: 14
filename:       /in/MiJ8K
function name:  validateSessionInfo
number of ops:  36
compiled vars:  !0 = $tokenInfo, !1 = $appId, !2 = $targetAppId
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  231     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      null
  234     2        INIT_STATIC_METHOD_CALL                                  '_getTargetAppId'
          3        SEND_VAR_EX                                              !1
          4        DO_FCALL                                      0  $3      
          5        ASSIGN                                                   !2, $3
  235     6        INIT_METHOD_CALL                                         !0, 'getAppId'
          7        DO_FCALL                                      0  $5      
          8        IS_NOT_IDENTICAL                                 ~6      !2, $5
          9      > JMPNZ_EX                                         ~6      ~6, ->14
  236    10    >   INIT_METHOD_CALL                                         !0, 'isValid'
         11        DO_FCALL                                      0  $7      
         12        BOOL_NOT                                         ~8      $7
         13        BOOL                                             ~6      ~8
         14    > > JMPNZ_EX                                         ~6      ~6, ->19
         15    >   INIT_METHOD_CALL                                         !0, 'getExpiresAt'
         16        DO_FCALL                                      0  $9      
         17        TYPE_CHECK                                    2  ~10     $9
         18        BOOL                                             ~6      ~10
         19    > > JMPNZ_EX                                         ~6      ~6, ->28
  237    20    >   INIT_METHOD_CALL                                         !0, 'getExpiresAt'
         21        DO_FCALL                                      0  $11     
         22        INIT_METHOD_CALL                                         $11, 'getTimestamp'
         23        DO_FCALL                                      0  $12     
         24        INIT_NS_FCALL_BY_NAME                                    'Facebook%5Ctime'
         25        DO_FCALL                                      0  $13     
         26        IS_SMALLER                                       ~14     $12, $13
         27        BOOL                                             ~6      ~14
         28    > > JMPZ                                                     ~6, ->34
  238    29    >   NEW                                              $15     'Facebook%5CFacebookSDKException'
  239    30        SEND_VAL_EX                                              'Session+has+expired%2C+or+is+not+valid+for+this+app.'
         31        SEND_VAL_EX                                              601
         32        DO_FCALL                                      0          
         33      > THROW                                         0          $15
  242    34    > > RETURN                                                   <true>
  243    35*     > RETURN                                                   null

End of function validatesessioninfo

Function newsessionfromsignedrequest:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 9, Position 2 = 12
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 17
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
filename:       /in/MiJ8K
function name:  newSessionFromSignedRequest
number of ops:  25
compiled vars:  !0 = $signedRequest, !1 = $state, !2 = $parsedRequest
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  254     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      null
  257     2        INIT_STATIC_METHOD_CALL                                  'parseSignedRequest'
          3        SEND_VAR_EX                                              !0
          4        SEND_VAR_EX                                              !1
          5        DO_FCALL                                      0  $3      
          6        ASSIGN                                                   !2, $3
  258     7        ISSET_ISEMPTY_DIM_OBJ                         0  ~5      !2, 'code'
          8      > JMPZ_EX                                          ~5      ~5, ->12
  259     9    >   ISSET_ISEMPTY_DIM_OBJ                         0  ~6      !2, 'oauth_token'
         10        BOOL_NOT                                         ~7      ~6
         11        BOOL                                             ~5      ~7
         12    > > JMPZ                                                     ~5, ->17
  260    13    >   INIT_STATIC_METHOD_CALL                                  'newSessionAfterValidation'
         14        SEND_VAR_EX                                              !2
         15        DO_FCALL                                      0  $8      
         16      > RETURN                                                   $8
  262    17    >   NEW                                              $9      'Facebook%5CFacebookSession'
         18        CHECK_FUNC_ARG                                           
         19        FETCH_DIM_FUNC_ARG                               $10     !2, 'oauth_token'
         20        SEND_FUNC_ARG                                            $10
         21        SEND_VAR_EX                                              !2
         22        DO_FCALL                                      0          
         23      > RETURN                                                   $9
  263    24*     > RETURN                                                   null

End of function newsessionfromsignedrequest

Function newsessionaftervalidation:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 30, Position 2 = 37
Branch analysis from position: 30
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 37
1 jumps found. (Code = 108) Position 1 = -2
filename:       /in/MiJ8K
function name:  newSessionAfterValidation
number of ops:  47
compiled vars:  !0 = $parsedSignedRequest, !1 = $params, !2 = $response
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  275     0  E >   RECV                                             !0      
  278     1        FETCH_STATIC_PROP_R          unknown             ~3      'defaultAppId'
          2        INIT_ARRAY                                       ~4      ~3, 'client_id'
  279     3        ADD_ARRAY_ELEMENT                                ~4      '', 'redirect_uri'
  281     4        FETCH_STATIC_PROP_R          unknown             ~5      'defaultAppSecret'
          5        ADD_ARRAY_ELEMENT                                ~4      ~5, 'client_secret'
  282     6        FETCH_DIM_R                                      ~6      !0, 'code'
          7        ADD_ARRAY_ELEMENT                                ~4      ~6, 'code'
  277     8        ASSIGN                                                   !1, ~4
  284     9        NEW                                              $8      'Facebook%5CFacebookRequest'
  285    10        INIT_STATIC_METHOD_CALL                                  'newAppSession'
         11        CHECK_FUNC_ARG                                           
  286    12        FETCH_STATIC_PROP_FUNC_ARG   unknown             $9      'defaultAppId'
         13        SEND_FUNC_ARG                                            $9
         14        CHECK_FUNC_ARG                                           
         15        FETCH_STATIC_PROP_FUNC_ARG   unknown             $10     'defaultAppSecret'
         16        SEND_FUNC_ARG                                            $10
         17        DO_FCALL                                      0  $11     
         18        SEND_VAR_NO_REF_EX                                       $11
  287    19        SEND_VAL_EX                                              'GET'
  288    20        SEND_VAL_EX                                              '%2Foauth%2Faccess_token'
  285    21        SEND_VAR_EX                                              !1
         22        DO_FCALL                                      0          
  290    23        INIT_METHOD_CALL                                         $8, 'execute'
         24        DO_FCALL                                      0  $13     
         25        INIT_METHOD_CALL                                         $13, 'getResponse'
         26        DO_FCALL                                      0  $14     
  284    27        ASSIGN                                                   !2, $14
  291    28        ISSET_ISEMPTY_DIM_OBJ                         0          !2, 'access_token'
         29      > JMPZ                                                     ~16, ->37
  292    30    >   NEW                                              $17     'Facebook%5CFacebookSession'
         31        CHECK_FUNC_ARG                                           
  293    32        FETCH_DIM_FUNC_ARG                               $18     !2, 'access_token'
         33        SEND_FUNC_ARG                                            $18
         34        SEND_VAR_EX                                              !0
         35        DO_FCALL                                      0          
         36      > RETURN                                                   $17
  296    37    >   INIT_STATIC_METHOD_CALL                                  'Facebook%5CFacebookRequestException', 'create'
  297    38        INIT_NS_FCALL_BY_NAME                                    'Facebook%5Cjson_encode'
         39        SEND_VAR_EX                                              !0
         40        DO_FCALL                                      0  $20     
         41        SEND_VAR_NO_REF_EX                                       $20
         42        SEND_VAR_EX                                              !0
  299    43        SEND_VAL_EX                                              401
         44        DO_FCALL                                      0  $21     
         45      > THROW                                         0          $21
  301    46*     > RETURN                                                   null

End of function newsessionaftervalidation

Function parsesignedrequest:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 120
Branch analysis from position: 8
2 jumps found. (Code = 46) Position 1 = 32, Position 2 = 35
Branch analysis from position: 32
2 jumps found. (Code = 43) Position 1 = 36, Position 2 = 114
Branch analysis from position: 36
2 jumps found. (Code = 43) Position 1 = 53, Position 2 = 58
Branch analysis from position: 53
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 58
1 jumps found. (Code = 42) Position 1 = 74
Branch analysis from position: 74
2 jumps found. (Code = 44) Position 1 = 79, Position 2 = 61
Branch analysis from position: 79
2 jumps found. (Code = 43) Position 1 = 81, Position 2 = 86
Branch analysis from position: 81
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 86
2 jumps found. (Code = 46) Position 1 = 89, Position 2 = 92
Branch analysis from position: 89
2 jumps found. (Code = 43) Position 1 = 93, Position 2 = 98
Branch analysis from position: 93
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 98
2 jumps found. (Code = 46) Position 1 = 99, Position 2 = 106
Branch analysis from position: 99
2 jumps found. (Code = 47) Position 1 = 102, Position 2 = 105
Branch analysis from position: 102
2 jumps found. (Code = 43) Position 1 = 107, Position 2 = 112
Branch analysis from position: 107
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 112
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 105
Branch analysis from position: 106
Branch analysis from position: 92
Branch analysis from position: 61
2 jumps found. (Code = 44) Position 1 = 79, Position 2 = 61
Branch analysis from position: 79
Branch analysis from position: 61
Branch analysis from position: 114
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 35
Branch analysis from position: 120
1 jumps found. (Code = 108) Position 1 = -2
filename:       /in/MiJ8K
function name:  parseSignedRequest
number of ops:  126
compiled vars:  !0 = $signedRequest, !1 = $state, !2 = $encodedSig, !3 = $encodedData, !4 = $sig, !5 = $data, !6 = $expectedSig, !7 = $validate, !8 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  313     0  E >   RECV                                             !0      
          1        RECV                                    

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
263.24 ms | 1428 KiB | 21 Q