Skip to content

Commit

Permalink
Changing signature strategy
Browse files Browse the repository at this point in the history
  • Loading branch information
sbellity committed Nov 1, 2011
1 parent fa4281e commit 4bf18c9
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions lib/OahuClient.php
Expand Up @@ -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);
Expand All @@ -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";
Expand Down

0 comments on commit 4bf18c9

Please sign in to comment.