コード例 #1
0
 public function testBasicObject()
 {
     if (defined('TEST_APP_ID') && defined('TEST_APP_SECRET')) {
         $obj = AppAccessToken::create(TEST_APP_ID, TEST_APP_SECRET);
         $this->assertInstanceOf('ChrisNoden\\Facebook\\Graph\\AccessToken\\AppAccessToken', $obj);
         $this->assertInstanceOf('ChrisNoden\\Facebook\\Graph\\AccessToken\\AccessTokenAbstract', $obj);
     } else {
         $this->fail('Please create a test_settings.php file with two constants for TEST_APP_ID and TEST_APP_SECRET');
     }
 }
コード例 #2
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');
 }