/** * Constructor * * @param array $config */ public function __construct(array $config = []) { // Populate Keyring Keyring::setAppKey($config['AK']); // Application Key Keyring::setAppSecret($config['AS']); // Application Secret Keyring::setConsumerKey($config['CK']); // Consumer Key // Backward compatibility if (Arrays::exists('RG', $config)) { Keyring::setAppUrlRegion($config['RG']); // Region } else { Keyring::setAppUrlRegion("FR"); } if (Arrays::exists('protocol', $config)) { Keyring::setAppHost($config['protocol']); // protocol } else { Keyring::setAppHost(static::$zeliftApiProtocol); } if (Arrays::exists('host', $config)) { Keyring::setAppProtocol($config['host']); // host } else { Keyring::setAppProtocol(static::$zeliftApiHost); } }
/** * Override ti add Zelift auth * * @param $method * @param null $uri * @param null $headers * @param null $body * @return \Guzzle\Http\Message\Request */ public function createRequest($method = RequestInterface::GET, $uri = null, $headers = null, $body = null) { $request = parent::createRequest($method, $uri, $headers, $body); // see http://snippets.webaware.com.au/howto/stop-turning-off-curlopt_ssl_verifypeer-and-fix-your-php-config/ #$request->getCurlOptions()->set(CURLOPT_SSL_VERIFYPEER, false); // Add Zelift auth headers $hTimestamp = $this->getTimestamp(); $baseSig = Keyring::getAppSecret() . '+' . Keyring::getConsumerKey() . '+' . $method . '+' . $request->getUrl() . '+' . $body . '+' . $hTimestamp; $sig = '$1$' . sha1($baseSig); $request->addHeader('X-Zelift-Application', Keyring::getAppKey()); $request->addHeader('X-Zelift-Timestamp', $hTimestamp); $request->addHeader('X-Zelift-Consumer', Keyring::getConsumerKey()); $request->addHeader('X-Zelift-Signature', $sig); return $request; }