Skip to content

Commit

Permalink
Merge pull request #28 from plivo/dev
Browse files Browse the repository at this point in the history
Added validate_signature function
  • Loading branch information
Charlie Chrisman committed Dec 3, 2015
2 parents b546daf + e1922a8 commit 23c11ff
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Add `plivo/plivo-php` as a dependency in your project's `composer.json` file:
```json
{
"require": {
"plivo/plivo-php": "v1.0.2"
"plivo/plivo-php": "v1.1.1"
}
}
```
Expand Down
9 changes: 9 additions & 0 deletions plivo.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,15 @@ function __construct($auth_id, $auth_token, $url = "https://api.plivo.com", $ver
$this->auth_token = $auth_token;
}

public static function validate_signature($uri, $post_params=array(), $signature, $auth_token) {
ksort($post_params);
foreach($post_params as $key => $value) {
$uri .= "$key$value";
}
$generated_signature = base64_encode(hash_hmac("sha1",$uri, $auth_token, true));
return $generated_signature == $signature;
}

private function request($method, $path, $params = array()) {
$url = $this->api.rtrim($path, '/').'/';

Expand Down

0 comments on commit 23c11ff

Please sign in to comment.