From 4bf18c98a102d394af062430051e8e45208d691b Mon Sep 17 00:00:00 2001 From: Stephane Bellity Date: Tue, 1 Nov 2011 20:05:34 +0100 Subject: [PATCH] Changing signature strategy --- lib/OahuClient.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/OahuClient.php b/lib/OahuClient.php index 01385cd..173cd43 100755 --- a/lib/OahuClient.php +++ b/lib/OahuClient.php @@ -44,6 +44,12 @@ function OahuConnection($oahuHost, $clientId, $consumerId, $consumerSecret, $noH } } + private function consumerSignature() { + $sig_time = mktime(); + $signature = md5(implode("-", array($this->clientId, $this->consumerSecret, $sig_time)); + return implode("|", array($sig_time, $signature)); + } + public function flushCache($delay=0) { if ($this->cache) { $this->cache->flush($delay); @@ -52,13 +58,12 @@ public function flushCache($delay=0) { } public function exec($type, $path, $params = array(), $headers = array()) { - // $params["consumer_id"] = $this->consumerId; - // $params["consumer_secret"] = $this->consumerSecret; $params["format"] = "json"; $headers[] = "Content-Type: application/json"; $headers[] = "CONSUMER_ID: " . $this->consumerId; - $headers[] = "CONSUMER_SECRET: " . $this->consumerSecret; - $url = "http://" . $this->oahuHost . "/v1/clients/" . $this->clientId . "/" . $path; + $headers[] = "CONSUMER_SIG: " . $this->consumerSignature(); + + $url = "http://" . $this->oahuHost . "/api/v1/clients/" . $this->clientId . "/" . $path; if ($this->noHttpCache) { $headers[] = "Cache-Control: no-cache";