Skip to content
This repository has been archived by the owner on Oct 3, 2023. It is now read-only.
/ PHP-Ziptastic Public archive

A PHP class used to access the Ziptastic API

Notifications You must be signed in to change notification settings

GRMule/PHP-Ziptastic

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PHP-Ziptastic

A simple PHP class used to access the Ziptastic API.

Sample usage:

$zt = new PHPZiptastic\Ziptastic(49504);

print $zt->city; // Grand Rapids

print $zt->lookup(34231)->city; // Sarasota

print $zt->lookup(44870); // Bloomingville, OH

print json_encode($zt); // {"city":"Bloomingville","state":"OH","zip":"44870"}

Errors and Exceptions

By default, errors (zip not found, malformed zip passed) will place a message in the $error property, and return a self-reference. This looks like:

print $zt->lookup(12344)->city; // null
print $zt->error; // Invalid zip code

If you would like to catch an exception instead, pass TRUE as a second constructor parameter:

$zt = new Ziptastic(null, true);
$zt->lookup(12344); // exception thrown here

OR

$zt = new Ziptastic(12344, true); // exception thrown here

For all errors, the exception throw is the base PHP Exception class.

Installation

Include Ziptastic.php or install the composer package.

Ziptastic

Ziptastic is a simple API that allows people to ask which Country,State and City are associated with a Zip Code.

More info at http://daspecster.github.com/ziptastic/

Many thanks to ElevenBaseTwo (http://blog.elevenbasetwo.com/) for shortening our forms!

About

A PHP class used to access the Ziptastic API

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages