dev-master
9999999-dev
The Requires
- php >=5.4.0
- illuminate/support 4.2.*
- guzzlehttp/guzzle ~4.0
The Development Requires
by Hao Luo
Wallogit.com
2017 © Pedro Peláez
An easy API wrapper for Socrata API using Guzzle, (*1)
in composer.json add following in require:, (*2)
"howlowck/socrata": "dev-master"
run php artisan config:publish howlowck/socrata then change the values according under app/config/packages/howlowck/socrata/config.php, (*3)
In app/config/app.php add the following in providers, (*4)
'Howlowck\Socrata\SocrataChicagoServiceProvider',
That will load the Socrata Chicago Data Portal routes, and register the wrapper as a singleton., (*5)
Create a Socrata Instance
If you didn't use the service provider, you can easily create a Socrata instance like so:, (*6)
$soc = new Howlowck\Socrata\Socrata($baseUrl, $secret_token, $public_token);
Create a Request
Without service provider (con't from above), (*7)
$request = $soc->createRequest('7as2-ds3y');
Or with service provider loaded for Chicago, (*8)
$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, (*9)
$request->where('number_of_potholes_filled_on_block>3');
$request->select('zip');
simple filter
You can also run any simple filters as methods., (*10)
$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, (*11)
To get JSON from response, (*12)
$response = $req->get(); $jsonResponse = $response->json();