GithubHelp home page GithubHelp logo

ziptastic / ziptastic-php Goto Github PK

View Code? Open in Web Editor NEW
8.0 5.0 2.0 25 KB

Official Ziptastic PHP Library

Home Page: https://www.getziptastic.com

License: MIT License

PHP 99.40% Shell 0.60%
php ziptastic ziptastic-php gis geocoder geocode forward reverse geographical-information-system zipcode

ziptastic-php's Introduction

Ziptastic PHP

Latest Stable Version Build Status Test Coverage

This library is a simple interface for the Ziptastic API.

Using Ziptastic requires an API key.

Installing

Ziptastic PHP can be installed via composer:

composer require ziptastic/ziptastic

Ziptastic PHP relies on HTTPlug to make API requests. HTTPlug is an abstraction which allows you to choose from any one of a large number of HTTP clients, including the client you might already have installed.

For more information on getting started with HTTPlug, please refer to the HTTPlug for library users documentation.

To just get moving right now, install a couple common dependencies:

composer require php-http/curl-client guzzlehttp/psr7 php-http/message

Usage

<?php

include "vendor/autoload.php";

use Ziptastic\Client;

$z = Client::create(getenv('ZIPTASTIC_API_KEY'));

Ziptastic provides two API methods: Lookup by a postal code (forward lookup), and lookup by latitude and longitude (reverse lookup).

$result = $z->forward(48038);
$result = $z->reverse(42.331427, -83.0457538, 1000);

Results are returned as a list of arrays:

<?php

$lookup = current($result);
echo $lookup['county']; // Macomb
echo $lookup['city']; // Clinton Township
echo $lookup['state']; // Michigan
echo $lookup['state_short']; // MI
echo $lookup['postal_code']; // 48038
echo $lookup['latitude']; // 42.5868882
echo $lookup['longitude']; // -82.9195514

// Timezones are represented by an instance of \DateTimeZone
echo $lookup['timezone']->getName(); // America/Detroit

PHP 5

If you require PHP 5 compatibility, please use Ziptastic-PHP version 1.

License

Ziptastic PHP is licensed under the MIT license.

ziptastic-php's People

Contributors

jdpedrie avatar michaelmackus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

ziptastic-php's Issues

Guzzle?

So, I've been keeping an eye on this repo and I have been wondering why not use Guzzle instead of a custom curl client?

Reverse geocoding support

Hey @austinkregel and @jdpedrie, if you guys are game for this, it would be awesome to add reverse geocoding support to this.

I had thought before of making it a separate repo but it shouldn't add a whole lot to this I don't think.

The API endpoint is simply https://zip.getziptastic.com/v3/<latitude>/<longitude>, and it requires an API key just like the current forward geocoding endpoint.

Let me know what you think?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.