/**
  * @param GetResponseEvent $event
  */
 public function onKernelRequest(GetResponseEvent $event)
 {
     $token = $this->tokenStorage->getToken();
     if (!$token instanceof OAuthToken) {
         return;
     }
     if ('foursquare' !== $token->getResourceOwnerName()) {
         return;
     }
     $this->client->addToken($token->getAccessToken());
 }
 /**
  * @param string $near
  * @param int    $offset
  *
  * @return array
  */
 public function explore($near, $offset = 0)
 {
     $venues = array();
     $params = array('near' => $near, 'radius' => 2000, 'section' => 'food', 'limit' => 50, 'offset' => $offset);
     $command = $this->foursquare->getCommand('venues/explore', $params);
     $results = $command->execute();
     foreach ($results['response']['groups'] as $group) {
         foreach ($group['items'] as $item) {
             $venues[] = $item['venue'];
         }
     }
     return $venues;
 }
 /**
  * @param $clientId
  * @param $clientSecret
  *
  * @dataProvider provideConfigValues
  */
 public function testAddToken($clientId, $clientSecret)
 {
     $config = array('client_id' => $clientId, 'client_secret' => $clientSecret);
     $token = 'secretToken';
     $client = FoursquareClient::factory($config);
     $client->addToken($token);
     $this->assertEquals($token, $client->getDefaultOption('query')['oauth_token']);
 }
 /**
  * @param $clientId
  * @param $clientSecret
  *
  * @dataProvider provideConfigValues
  */
 public function testAddToken($clientId, $clientSecret)
 {
     $config = ['client_id' => $clientId, 'client_secret' => $clientSecret];
     $token = 'secretToken';
     $client = FoursquareClient::factory($config);
     $client->setToken($token);
     $defaultOptions = $client->getHttpClient()->getDefaultOption('query');
     $this->assertEquals($token, $defaultOptions['oauth_token']);
 }
 public function init()
 {
     parent::init();
     $this->client = FoursquareClient::factory(['client_id' => $this->clientId, 'client_secret' => $this->secret]);
     $accessToken = !empty(Yii::$app->session) ? Yii::$app->session->get('fsAccessToken') : null;
     if ($accessToken !== null) {
         $this->setAccessToken($accessToken);
     }
 }
 /**
  * Initializes the options for the object
  *
  * Called from {@link __construct()} as a first step of object instantiation.
  *
  * @param   ObjectConfig $object An optional ObjectConfig object with configuration options
  * @return  void
  */
 protected function _initialize(Library\ObjectConfig $config)
 {
     $config->append(array('client_id' => '', 'client_secret' => '', 'token' => null, 'redirect_url' => null, 'token' => null, 'v' => '20150301'))->append(array('delegate' => FoursquareClient::factory($config->toArray())->setDefaultOption('query', array('client_id' => $config->client_id, 'client_secret' => $config->client_secret, 'v' => $config->v))));
     parent::_initialize($config);
 }
Esempio n. 7
0
 function __construct(Cafe $client)
 {
     $this->{$client} = FoursquareClient::factory(array('client_id' => 'I4KDF1MRZJVXXWK4R110HSJ2W3SJPGO4LI5DMDHXFCKOETRL', 'client_secret' => 'O4YHUXYWDVMLVIMPWWCPKBONZAK5XIHMGIHW1ZHCPICZ3OIR'));
 }