dev-master
9999999-dev https://github.com/r-baker/3taps-php-clientClient library for 3taps data commons APIs (https://3taps.com). Built on top of Guzzle.
Apache-2.0
The Requires
The Development Requires
by R Baker
api rest guzzle 3taps
Client library for 3taps data commons APIs (https://3taps.com). Built on top of Guzzle.
A PHP 5.3+ client for working with the 3taps APIs.
, (*1)
composer.phar require r-baker/3taps-php-client
use Rbaker\ThreeTaps\ThreeTapsService; $service = ThreeTapsService::factory(array( 'auth_token' => 'your-private-auth-token' ));
$referenceClient = $service->get('reference');
$categories = $referenceClient->getCategories();
All methods and parameters from each of the three APIs (as defined in the 3taps API docs) are supported., (*2)
To use an API client, as in the example above, you must instantiate a relevant client instance from the service instance. API methods may then be called on the client instance., (*3)
If desired, an array of parameters may be passed into the second argument of an API method call. The PHP client will ensure all required parameters are provided, but be sure to consult the API documentation for all optional params., (*4)
The Reference API client supports the following methods:, (*5)
3Taps Method Name | PHP Client Method Name |
---|---|
sources | $referenceClient->getSources() |
category_groups | $referenceClient->getCategoryGroups() |
categories | $referenceClient->getCategories() |
locations | $referenceClient->getLocations() |
location lookups | $referenceClient->locationLookup() |
$referenceClient = $service->get('reference'); $data = $referenceClient->locationLookup(array( 'code'=>'USA-AL' ));
The Search API client supports the follwing methods:, (*6)
3Taps Method Name | PHP Client Method Name |
---|---|
search | $searchClient->search() |
count mode | $searchClient->count() |
$searchClient = $service->get('search'); $iterator = $searchClient->getIterator('search', array( 'category_group' => 'JJJJ' )); $iterator->setLimit(30); // Total number of (unlimited) results matching our request echo $iterator->getNumMatches(); // grab results print_r($iterator->toArray());
The Polling API client supports the follwing methods:, (*7)
3Taps Method Name | PHP Client Method Name |
---|---|
anchor | $pollingClient->getAnchor() |
poll | $pollingClient->poll() |
Please see the complete example below., (*8)
Result iterators automatically implement much of the logic required for working with pages of results. In the case of the 3taps Search and Polling APIs, the page, anchor and tier parameters are taken care of and automatically parameterized for subsequent requests. This allows you to simply set the number of results you need, and the iterator will attempt (if required) to make as many API calls as needed return your result set., (*9)
Retrieve an anchor from the polling API and poll for all job-related postings in NYC, placed in the last 3 hours., (*10)
<?php require 'vendor/autoload.php'; use Rbaker\ThreeTaps\ThreeTapsService; // create service instance $service = ThreeTapsService::factory(array( 'auth_token' => 'your-private-auth-token' )); $pollingClient = $service->get('polling'); // retrieve anchor $anchor = $pollingClient->getAnchor(array( 'timestamp' => strtotime('-3 hours') )); // retrieve results $iterator = $pollingClient->getIterator('poll', array( 'category_group' => 'JJJJ', 'location.city' => 'USA-NYM-NEY', 'anchor' => $anchor['anchor'] )); // iterate! foreach($iterator as $result) { print_r($result); } // grab the anchor to use for the next poll request $nextAnchor = $iterator->getAnchor();
The project includes a basic PHPUnit test suite for each API client., (*11)
php composer.phar install --dev
auth_token
to your phpunit.xml configuration./vendor/bin/phpunit
Client library for 3taps data commons APIs (https://3taps.com). Built on top of Guzzle.
Apache-2.0
api rest guzzle 3taps