-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from texdc/feature-namespace
Add namespace and test
- Loading branch information
Showing
9 changed files
with
364 additions
and
221 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
.DS_Store | ||
|
||
/vendor/ | ||
/vendor | ||
/composer.lock | ||
/phpunit.xml | ||
/build | ||
|
||
# Ignore eclipse project files | ||
.settings | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,28 @@ | ||
{ | ||
"name": "socrata/soda-php", | ||
"description": "A simple library to make it easier to access SODA services from PHP", | ||
"keywords": ["SODA", "socrata"], | ||
"keywords": ["SODA", "socrata", "open data", "sdk"], | ||
"homepage": "http://dev.socrata.com", | ||
"license": "Apache-2.0", | ||
"require": { | ||
"php": "~5.3", | ||
"ext-curl": "*" | ||
"ext-curl": "*", | ||
"ext-json": "*" | ||
}, | ||
"require-dev": { | ||
"phpunit/phpunit": "@stable" | ||
}, | ||
"autoload": { | ||
"files": ["public/socrata.php"] | ||
"psr-4": { | ||
"socrata\\soda\\": "src" | ||
} | ||
}, | ||
"autoload-dev": { | ||
"psr-4": { | ||
"socrata\\soda\\test\\": "test" | ||
} | ||
}, | ||
"archive": { | ||
"exclude": ["public", "test"] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="http://phpunit.de/phpunit.xsd" | ||
bootstrap="./test/config/bootstrap.php" backupGlobals="false" verbose="true" colors="true"> | ||
|
||
<testsuites> | ||
<testsuite name="soda"> | ||
<directory suffix="Test.php">./test</directory> | ||
</testsuite> | ||
</testsuites> | ||
|
||
<logging> | ||
<log type="coverage-text" target="php://stdout" showUncoveredFiles="false" | ||
lowUpperBound="50" highLowerBound="80" /> | ||
<log type="coverage-clover" target="./build/logs/clover.xml" /> | ||
</logging> | ||
|
||
<filter> | ||
<whitelist processUncoveredFilesFromWhitelist="true"> | ||
<directory suffix=".php">./src</directory> | ||
<exclude> | ||
<directory>./vendor</directory> | ||
<directory>./test</directory> | ||
</exclude> | ||
</whitelist> | ||
</filter> | ||
|
||
<php> | ||
<const name="PHPUNIT_TESTSUITE" value="true" /> | ||
</php> | ||
|
||
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,67 +1,67 @@ | ||
<?php | ||
require_once("socrata.php"); | ||
if (file_exists("../vendor/autoload.php")) { | ||
require_once "../vendor/autoload.php"; | ||
} else { | ||
require_once "../src/Client.php"; | ||
} | ||
|
||
$view_uid = "ykw4-j3aj"; | ||
$root_url = "https://data.austintexas.gov"; | ||
$app_token = "B0ixMbJj4LuQVfYnz95Hfp3Ni"; | ||
$response = NULL; | ||
use socrata\soda\Client; | ||
|
||
$latitude = array_get("latitude", $_POST); | ||
$longitude = array_get("longitude", $_POST); | ||
$range = array_get("range", $_POST); | ||
// Convenience functions | ||
function array_get($needle, array $haystack, $default = NULL) { | ||
return isset($haystack[$needle]) ? $haystack[$needle] : $default; | ||
} | ||
|
||
if($latitude != NULL && $longitude != NULL && $range != NULL) { | ||
// Create a new unauthenticated client | ||
$socrata = new Socrata($root_url, $app_token); | ||
function pre_dump($var) { | ||
echo "<pre>" . print_r($var) . "</pre>"; | ||
} | ||
|
||
$params = array("\$where" => "within_circle(location, $latitude, $longitude, $range)"); | ||
$view_uid = "y9us-9xdf"; | ||
$root_url = "https://data.medicare.gov"; | ||
$footnote = array_get("footnote", $_POST); | ||
|
||
$response = $socrata->get("/resource/$view_uid.json", $params); | ||
} | ||
// Create a new unauthenticated client | ||
$sodaClient = new Client($root_url); | ||
$params = array(); | ||
|
||
if (!empty($footnote)) { | ||
$params['$where'] = "footnote=$footnote"; | ||
} | ||
|
||
$response = $sodaClient->get("/resource/{$view_uid}.json", $params); | ||
?> | ||
<html> | ||
<head> | ||
<title>Austin Dangerous Dogs</title> | ||
<title>Medicare Footnote Crosswalk</title> | ||
</head> | ||
<body> | ||
<h1>Austin Dangerous Dogs</h1> | ||
|
||
<?php if($response == NULL) { ?> | ||
<form action="index.php" method="POST"> | ||
<p>Try 30.27898, -97.68351 with a range of 1000 meters</p> | ||
|
||
<label for="latitude">Latitude</label> | ||
<input type="text" name="latitude" size="10" value="30.27898"/><br/> | ||
|
||
<label for="longitude">Longitude</label> | ||
<input type="text" name="longitude" size="10" value="-97.68351"/><br/> | ||
|
||
<label for="range">Range</label> | ||
<input type="text" name="range" size="10" value="1000"/><br/> | ||
|
||
<input type="submit" value="Submit"/> | ||
</form> | ||
<?php } else { ?> | ||
<h1>Medicare Footnote Crosswalk</h1> | ||
<p><?= $root_url . "/resource/{$view_uid}.json" ?></p> | ||
<form method="POST"> | ||
<label>Footnote: <input type="number" name="footnote" value="<?= $footnote ?>" /></label> | ||
<input type="submit" value="Search" /> | ||
</form> | ||
<?php if (!isset($response['error'])) : ?> | ||
<h2>Results</h2> | ||
|
||
<?# Create a table for our actual data ?> | ||
<table border="1"> | ||
<tr> | ||
<th>Description</th> | ||
<th>Address</th> | ||
<th>Footnote</th> | ||
<th>Footnote Text</th> | ||
</tr> | ||
<?# Print rows ?> | ||
<?php foreach($response as $row) { ?> | ||
<?php foreach($response as $row) : ?> | ||
<tr> | ||
<td><?= $row["description_of_dog"] ?></td> | ||
<td><?= $row["address"] ?></td> | ||
<td><?= $row["footnote"] ?></td> | ||
<td><?= $row["footnote_text"] ?></td> | ||
</tr> | ||
<?php } ?> | ||
<?php endforeach; ?> | ||
</table> | ||
<?php endif; ?> | ||
|
||
<h3>Raw Response</h3> | ||
<pre><?= var_dump($response) ?></pre> | ||
<?php } ?> | ||
<h3>Raw Response</h3> | ||
<pre><?= var_dump($response) ?></pre> | ||
</body> | ||
</html> | ||
|
Oops, something went wrong.