コード例 #1
0
 /**
  * @param string $app_id
  * @param string $app_secret
  *
  * @return AppAccessToken
  */
 public static function create($app_id, $app_secret)
 {
     $token = new AppAccessToken();
     $token->setAppId($app_id);
     $token->setAppSecret($app_secret);
     return $token;
 }
コード例 #2
0
 public function testObjectLoadFromFacebook()
 {
     if (defined('TEST_APP_ID') && defined('TEST_APP_SECRET')) {
         $obj = new AppAccessToken();
         $obj->setAppId(TEST_APP_ID);
         $obj->setAppSecret(TEST_APP_SECRET);
         $access_token = $obj->getAccessToken();
         $arr = explode('|', $access_token);
         $this->assertEquals(TEST_APP_ID, $arr[0]);
         $this->access_token = $access_token;
         $token_info = $obj->getTokenInfo($access_token);
     }
 }
コード例 #3
0
 /**
  * The Application access_token for Facebook authentication
  *
  * @return string
  * @throws InvalidArgumentException if a problem fetching the app access_token
  */
 public function getAccessToken()
 {
     if (!isset($this->access_token)) {
         if ($this->getFieldValue('id') !== null && isset($this->app_secret)) {
             $this->access_token = AppAccessToken::create($this->getFieldValue('id'), $this->app_secret);
         }
     }
     if ($this->access_token instanceof AppAccessToken) {
         return $this->access_token->getAccessToken();
     }
     throw new InvalidArgumentException('Unable to fetch access token');
 }