File: readme_APIKey.txt

Recommend this page to a friend!
  Classes of Ray Paseur  >  Lightweight PHP API Key Authentication  >  readme_APIKey.txt  >  Download  
File: readme_APIKey.txt
Role: Documentation
Content type: text/plain
Description: Readme text file
Class: Lightweight PHP API Key Authentication
Store and validate user API keys in files
Author: By
Last change:
Date: 2 years ago
Size: 1,197 bytes



Class file image Download
readme for class_APIKey.php

This set of classes is a response to a request at this URL:

There are 3 classes in the set:

Abstract class APIKey
This is the base class that the other classes extend.  It has one method, generate(),
which creates a unique API key.  It also defines two other methods.  Method validate()
test a given API key for validity and returns the name of the person it belongs to, or
throws APIKeyException.  Method storeKey() takes the name of a person, calls generate()
to get a new API key, and stores the name:key combination in a place that validate()
can find.

Class APIKeyValidation
This is the concrete class that provides the two abstract methods called for by APIKey.
When validate() cannot associate an API key with a user name it throws APIKeyException.

Class APIKeyException
Extends Exception and provides a message and an HTTP code.

There are 2 demonstration files in hte set:

Script demo_APIKey.php exercises the classes.
Text File demo_APIKey.txt simulates a database or flat file of valid API keys.

Add a method to invalidate an API key.

For more information send a message to info at phpclasses dot org.