Example #1
0
 /**
  * Turns and authorized interaction into a usable api session. 
  * 
  * @return session key, expires, uid.
  */
 public function execute()
 {
     //       echo " Calling Auth Get Session today ";
     $response = array();
     if ($this->getUserId() == null || $this->getSessionValue(self::SESSION_APPROVED) != true) {
         throw new OpenFBAPIException("Authorization token not approved.", FB_ERROR_CODE_UNKNOWN_ERROR);
     }
     $infinite = false;
     if ($this->getSessionValue(self::SESSION_INFINITE) == 'true') {
         $infinite = true;
     }
     // Create session and return session id.
     session_regenerate_id(true);
     $sid = session_id();
     if ($infinite === true) {
         Session::mark_infinite($sid);
     }
     $this->setSessionValue(self::SESSION_TYPE, self::SESSION_TYPE_VALUE_SESS);
     $this->setSessionValue(self::SESSION_CALL_ID, 0);
     if ($infinite === true) {
         //			error_log("Authorized infinite session for ".$this->getUserId());
         $this->setSessionValue(self::SESSION_EXPIRES, self::SESSION_EXPIRES_VALUE_NEVER);
     } else {
         $this->setSessionValue(self::SESSION_EXPIRES, time() + 24 * 60 * 60);
     }
     $response[self::RESPONSE_SESSION_KEY] = $sid . '-ringside';
     $response[self::RESPONSE_EXPIRES] = $this->getSessionValue(self::SESSION_EXPIRES);
     $response[self::RESPONSE_USER_ID] = $this->getUserId();
     // Persist link to the session information
     $uas = Api_Bo_App::setUserAppSession($this->getAppId(), $this->getUserId(), $infinite, $sid);
     return $response;
 }