howlowck / socrata
Requires
- php: >=5.4.0
- guzzlehttp/guzzle: ~4.0
- illuminate/support: 4.2.*
Requires (Dev)
- mockery/mockery: dev-master
- phpunit/phpunit: 4.2.*
This package is not auto-updated.
Last update: 2024-12-17 03:32:04 UTC
README
An easy API wrapper for Socrata API using Guzzle
Feature
- Easily intergrates with Laravel
- Chicago Service provider
"Install"
add to composer.json
in composer.json
add following in require
:
"howlowck/socrata": "dev-master"
set configuration file (optional)
run php artisan config:publish howlowck/socrata
then change the values according under app/config/packages/howlowck/socrata/config.php
add service provider (optional)
In app/config/app.php
add the following in providers
'Howlowck\Socrata\SocrataChicagoServiceProvider',
That will load the Socrata Chicago Data Portal routes, and register the wrapper as a singleton.
Usage
Create a Socrata Instance
If you didn't use the service provider, you can easily create a Socrata instance like so:
$soc = new Howlowck\Socrata\Socrata($baseUrl, $secret_token, $public_token);
Create a Request
Without service provider (con't from above)
$request = $soc->createRequest('7as2-ds3y');
Or with service provider loaded for Chicago
$request = App::make('socrata-chicago')->createRequest('7as2-ds3y');
filter on Socrata datasource with SoQL query
You can use query keywards outlined on socrata's site as methods
$request->where('number_of_potholes_filled_on_block>3'); $request->select('zip');
simple filter
You can also run any simple filters as methods.
$req->service_request_number('11-00026951');
get Response
Response will be return as GuzzleHttp\Message\Response which then can be turned into number of formats
To get JSON from response
$response = $req->get(); $jsonResponse = $response->json();