Example #1
0
 /**
  * @param $consumerKey
  * @param $consumerSecret
  * @param $token
  * @param $tokenSecret
  *
  * @return self
  */
 public static function factory($consumerKey, $consumerSecret, $token, $tokenSecret)
 {
     $client = new self(['base_url' => ['https://api.twitter.com/{version}/', ['version' => 'v1.1']], 'defaults' => ['auth' => 'oauth']]);
     $oauth = new Oauth1(['consumer_key' => $consumerKey, 'consumer_secret' => $consumerSecret, 'token' => $token, 'token_secret' => $tokenSecret]);
     $client->getEmitter()->attach($oauth);
     return $client;
 }
Example #2
0
 /**
  * Gets a new NovaPoshtaClient.
  *
  * @param array $config
  *   GuzzleHttp\Command\Guzzle\GuzzleClient $config options.
  * @param array $http_config
  *   GuzzleHttp\Client $config options.
  *
  * @return NovaPoshtaClient
  *   An wrapped GuzzleClient.
  */
 public static function factory($config = [], $http_config = [])
 {
     $description_path = __DIR__ . '/Resources/novaposhta-json-v2.php';
     $description = new Description(include $description_path);
     $defaults = [];
     $config = array_merge($defaults, $config);
     $http_client = new HttpClient($http_config);
     $client = new self($http_client, $description, $config);
     $emitter = $client->getEmitter();
     $emitter->attach(new ResponseWrapper());
     $emitter->attach(new ErrorHandlerListener($description));
     $emitter->attach(new CommandWrapper());
     return $client;
 }