static $_apiURL = 'http://api.sunlightlabs.com/';
static $_apiKey = NULL;
+ /**
+ * @param $uri
+ *
+ * @return SimpleXMLElement
+ * @throws Exception
+ */
static function makeAPICall($uri) {
require_once 'HTTP/Request.php';
$params = array(
return simplexml_load_string($string);
}
+ /**
+ * @param $zipcode
+ *
+ * @return array
+ */
static function getCityState($zipcode) {
$key = self::$_apiKey;
$uri = "places.getCityStateFromZip.php?zip={$zipcode}&apikey={$key}&output=xml";
return array($xml->city, $xml->state);
}
+ /**
+ * @param $peopleID
+ *
+ * @return array
+ */
static function getDetailedInfo($peopleID) {
$key = self::$_apiKey;
$uri = "people.getPersonInfo.php?id={$peopleID}&apikey={$key}&output=xml";
return $result;
}
+ /**
+ * @param $uri
+ *
+ * @return array
+ */
static function getPeopleInfo($uri) {
$xml = self::makeAPICall($uri);
return $result;
}
+ /**
+ * @param $city
+ * @param $state
+ *
+ * @return array|null
+ */
static function getRepresentativeInfo($city, $state) {
if (!$city ||
!$state
return self::getPeopleInfo($uri);
}
+ /**
+ * @param $state
+ *
+ * @return array|null
+ */
static function getSenatorInfo($state) {
if (!$state) {
return NULL;
return self::getPeopleInfo($uri);
}
+ /**
+ * @param $city
+ * @param $state
+ * @param null $zipcode
+ *
+ * @return array
+ */
static function getInfo($city, $state, $zipcode = NULL) {
if ($zipcode) {
list($city, $state) = self::getCityState($zipcode);