Exemplo n.º 1
0
 /**
  * {@inheritDoc}
  */
 public function storeAccessToken($serviceName, TokenInterface $token)
 {
     // normalize service name
     $serviceName = ucfirst($serviceName);
     parent::storeAccessToken($serviceName, $token);
     $this->configs[$serviceName][self::ACCES_TOKEN_KEY] = serialize($token);
     $this->save($serviceName);
     // allow chaining
     return $this;
 }
Exemplo n.º 2
0
 /**
  * Get the Flickr service.
  * @return AbstractService
  */
 public function getService()
 {
     //      if ( $this->flickrService instanceof ServiceInterface ) {
     //          return $this->flickrService;
     //      }
     $credentials = new Credentials($this->apiKey, $this->apiSecret, 'oob');
     $storage = new Memory();
     $accessToken = $this->getStoredCredentials();
     if ($accessToken instanceof TokenInterface) {
         $storage->storeAccessToken('Flickr', $accessToken);
     }
     $serviceFactory = new ServiceFactory();
     $this->flickrService = $serviceFactory->createService('Flickr', $credentials, $storage);
     return $this->flickrService;
 }
Exemplo n.º 3
0
 private function getTwitterService()
 {
     $key = TWITTER_APP_CONSUMER_KEY;
     $secret = TWITTER_APP_CONSUMER_SECRET;
     $access_token = TWITTER_APP_ACCESS_TOKEN;
     $access_secret = TWITTER_APP_ACCESS_SECRET;
     /** @var \OAuth\ServiceFactory $factory */
     $factory = \Core::make('oauth/factory/service');
     // Initialize the token
     $token = new StdOAuth1Token($access_token);
     $token->setAccessTokenSecret($access_secret);
     // Store the token in memory
     $storage = new Memory();
     $storage->storeAccessToken('Twitter', $token);
     // Create the twitter service
     return $factory->createService('twitter', new Credentials($key, $secret, ''), $storage);
 }
Exemplo n.º 4
0
 /**
  * @covers OAuth\Common\Storage\Memory::__construct
  * @covers OAuth\Common\Storage\Memory::storeAccessToken
  * @covers OAuth\Common\Storage\Memory::clearAllTokens
  */
 public function testClearAllTokens()
 {
     $storage = new Memory();
     $storage->storeAccessToken('foo', $this->getMock('\\OAuth\\Common\\Token\\TokenInterface'));
     $storage->storeAccessToken('bar', $this->getMock('\\OAuth\\Common\\Token\\TokenInterface'));
     $this->assertTrue($storage->hasAccessToken('foo'));
     $this->assertTrue($storage->hasAccessToken('bar'));
     $this->assertInstanceOf('\\OAuth\\Common\\Storage\\Memory', $storage->clearAllTokens());
     $this->assertFalse($storage->hasAccessToken('foo'));
     $this->assertFalse($storage->hasAccessToken('bar'));
 }