public function testAnAccessTokenCanBeSetFromTheParams()
 {
     $app = new FacebookApp('123', 'foo_secret');
     $request = new FacebookRequest($app, null, 'POST', '/me', ['access_token' => 'bar_token']);
     $accessToken = $request->getAccessToken();
     $this->assertEquals('bar_token', $accessToken);
 }
Esempio n. 2
0
 /**
  * Ensures that the FacebookApp and access token fall back when missing.
  *
  * @param FacebookRequest $request
  *
  * @throws FacebookSDKException
  */
 public function addFallbackDefaults(FacebookRequest $request)
 {
     if (!$request->getApp()) {
         $app = $this->getApp();
         if (!$app) {
             throw new FacebookSDKException('Missing FacebookApp on FacebookRequest and no fallback detected on FacebookBatchRequest.');
         }
         $request->setApp($app);
     }
     if (!$request->getAccessToken()) {
         $accessToken = $this->getAccessToken();
         if (!$accessToken) {
             throw new FacebookSDKException('Missing access token on FacebookRequest and no fallback detected on FacebookBatchRequest.');
         }
         $request->setAccessToken($accessToken);
     }
 }
 private function assertRequestContainsAppAndToken(FacebookRequest $request, FacebookApp $expectedApp, $expectedToken)
 {
     $app = $request->getApp();
     $token = $request->getAccessToken();
     $this->assertSame($expectedApp, $app);
     $this->assertEquals($expectedToken, $token);
 }