Created
December 17, 2013 19:00
-
-
Save bentigano/8010651 to your computer and use it in GitHub Desktop.
Retrieves HUD housing counseling agencies using their API.
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
<?php | |
function getClosestHousingCouncelingAgencies($latitude, $longitude, $limit = 10, &$debugData) { | |
$apiURL = 'http://data.hud.gov/Housing_Counselor/searchByLocation'; | |
$distance = 25; | |
$agencies = array(); | |
$apiURL = $apiURL . '?Lat=' . $latitude . '&Long=' . $longitude . '&Distance=' . $distance . '&RowLimit=&Services=&Languages='; | |
$debugData .= 'API: ' . $apiURL . ' <br/>'; | |
$file = file_get_contents($apiURL); | |
if ($file != false) { | |
$jsonObject = json_decode($file); | |
if (is_array($jsonObject)) { | |
foreach ($jsonObject as $item) { | |
$agencies[] = $item; | |
$debugData .= 'Adding item: ' . $item->agcid . ' <br/>'; | |
} | |
} | |
} | |
return $agencies; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment