/** * Override ti add OVH 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 OVH auth headers $hTimestamp = $this->getTimestamp(); # SIG = "$1$" + sha1.hex(AS+"+"+CK+"+"+METHOD+"+"+QUERY+"+"+BODY +"+"+TSTAMP) #var_dump($body); #print $body; #die(); #if ($method == "POST") # $baseSig = Keyring::getAppSecret() . '+' . Keyring::getConsumerKey() . '+' . $method . '+' . $request->getUrl() . '+' . '' . '+' . $hTimestamp; #else $baseSig = Keyring::getAppSecret() . '+' . Keyring::getConsumerKey() . '+' . $method . '+' . $request->getUrl() . '+' . $body . '+' . $hTimestamp; # #print $baseSig . "\n"; $sig = '$1$' . sha1($baseSig); #print $sig . "\n"; $request->addHeader('X-Ovh-Application', Keyring::getAppKey()); $request->addHeader('X-Ovh-Timestamp', $hTimestamp); $request->addHeader('X-Ovh-Consumer', Keyring::getConsumerKey()); $request->addHeader('X-Ovh-Signature', $sig); return $request; }
/** * Constructor * * @param array $config */ public function __construct(array $config = array()) { // Populate keyring Keyring::setAppKey($config['AK']); // Application Key Keyring::setAppSecret($config['AS']); // Application Secret Keyring::setConsumerKey($config['CK']); // Consumer Key // Backward compatibility if (array_key_exists('RG', $config)) { keyring::setAppUrlRegion($config['RG']); // Region } else { keyring::setAppUrlRegion("FR"); } }