{"id":19177733,"url":"https://github.com/jessety/simple-hmac-auth-php","last_synced_at":"2026-06-20T11:31:46.860Z","repository":{"id":77098944,"uuid":"159358502","full_name":"jessety/simple-hmac-auth-php","owner":"jessety","description":"PHP library for interfacing with APIs that implement hmac signatures ","archived":false,"fork":false,"pushed_at":"2019-03-06T17:35:44.000Z","size":16,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-23T01:20:48.980Z","etag":null,"topics":["api-security","hmac-authentication","php","request-signatures","request-signing","simple-hmac-auth"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jessety.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-11-27T15:37:11.000Z","updated_at":"2021-01-27T19:58:19.000Z","dependencies_parsed_at":null,"dependency_job_id":"ea8dff3f-84e8-4a8f-b040-f06ef9ee1f89","html_url":"https://github.com/jessety/simple-hmac-auth-php","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/jessety/simple-hmac-auth-php","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jessety%2Fsimple-hmac-auth-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jessety%2Fsimple-hmac-auth-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jessety%2Fsimple-hmac-auth-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jessety%2Fsimple-hmac-auth-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jessety","download_url":"https://codeload.github.com/jessety/simple-hmac-auth-php/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jessety%2Fsimple-hmac-auth-php/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34568741,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-20T02:00:06.407Z","response_time":98,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api-security","hmac-authentication","php","request-signatures","request-signing","simple-hmac-auth"],"created_at":"2024-11-09T10:34:55.293Z","updated_at":"2026-06-20T11:31:46.841Z","avatar_url":"https://github.com/jessety.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# simple-hmac-auth-php\nPHP library for interfacing with APIs that implement HMAC signatures. Designed for use with a JSON API that implements [simple-hmac-auth](https://github.com/jessety/simple-hmac-auth).\n\n### Usage\n\nInstantiate a client object and point it at your service\n\n```php\n\nrequire_once('SimpleHMACAuthClient.php');\n\n$client = new SimpleHMACAuthClient('API_KEY', 'SECRET');\n\n$client-\u003ehost = 'localhost';\n$client-\u003eport = 8000;\n$client-\u003essl = false;\n\n```\n\nGET request\n\n```php\ntry {\n  \n  $items = $client-\u003ecall('GET', '/items/');\n\n  die('Success: \u003cpre\u003e' . json_encode($items, JSON_PRETTY_PRINT) . '\u003c/pre\u003e');\n\n} catch (AuthenticationException $e) {\n\n  die('Failure: \u003cpre\u003e' . json_encode($e, JSON_PRETTY_PRINT) . '\u003c/pre\u003e');\n}\n```\n\nPOST request with body data and query string\n\n```php\ntry {\n\n  $query = array(\n    'debug' =\u003e true\n  );\n\n  $data = array(\n    'test' =\u003e true,\n    'created' =\u003e microtime(true)\n  );\n\n  // Create a new item\n  $client-\u003ecall('POST', '/items/', $query, $data);\n  \n  die('Success!');\n\n} catch (AuthenticationException $e) {\n\n  die('Failure: \u003cpre\u003e' . json_encode($e, JSON_PRETTY_PRINT) . '\u003c/pre\u003e');\n}\n```\n\n### Client Subclass\n\nTo write a client for your service, simply extend the class and add functions that match your API routes.\n\n```php\nclass SampleClient extends SimpleHMACAuthClient {\n\n  public function __construct($apiKey, $secret) {\n    parent::__construct($apiKey, $secret);\n\n    // Define the host / port / SSL of your service in the constructor\n    $this-\u003ehost = 'localhost';\n    $this-\u003eport = 8000;\n    $this-\u003essl = false;\n  }\n\n  public function create($data = array()) {\n\n    return $this-\u003ecall('POST', '/items/', null, $data);\n  }\n\n  public function query($parameters = array()) {\n\n    return $this-\u003ecall('GET', '/items/', $parameters);\n  }\n\n  public function detail($id = null) {\n\n    if ($id === null) {\n      throw new AuthenticationException('Missing \\'id\\' parameter');\n    }\n\n    return $this-\u003ecall('GET', '/items/' . rawurlencode($id));\n  }\n\n  public function update($id = null, $data = array()) {\n\n    if ($id === null) {\n      throw new AuthenticationException('Missing \\'id\\' parameter');\n    }\n\n    return $this-\u003ecall('POST', '/items/' . rawurlencode($id), null, $data);\n  }\n\n  public function delete($id = null) {\n\n    if ($id === null) {\n      throw new AuthenticationException('Missing \\'id\\' parameter');\n    }\n\n    return $this-\u003ecall('DELETE', '/items/' . rawurlencode($id));\n  }\n}\n```\n\nBecause this client's constructor specified the host, port, and SSL status of the service, it can be instantiated without any parameters beyond `apiKey` and `secret`. \n\n```php\n$client = new SampleClient('API_KEY', 'SECRET'); \n\ntry {\n\n  $parameters = array(\n    'debug' =\u003e true,\n    'limit' =\u003e 42\n  );\n\n  $items = $client-\u003equery($parameters);\n\n  die('Success: \u003cpre\u003e' . json_encode($items, JSON_PRETTY_PRINT) . '\u003c/pre\u003e');\n\n} catch (AuthenticationException $e) {\n\n  die('Failure: \u003cpre\u003e' . json_encode($e, JSON_PRETTY_PRINT) . '\u003c/pre\u003e');\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjessety%2Fsimple-hmac-auth-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjessety%2Fsimple-hmac-auth-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjessety%2Fsimple-hmac-auth-php/lists"}