2017 © Pedro Peláez
 

library socrata

image

howlowck/socrata

  • Monday, August 18, 2014
  • by howlowck
  • Repository
  • 3 Watchers
  • 1 Stars
  • 4 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

# Socrata

An easy API wrapper for Socrata API using Guzzle, (*1)

Feature

  • Easily intergrates with Laravel
  • Chicago Service provider

"Install"

add to composer.json

in composer.json add following in require:, (*2)

"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, (*3)

add service provider (optional)

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)

Usage

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();

The Versions

18/08 2014