diff --git a/conf/openstates.php b/conf/openstates.php new file mode 100644 index 0000000..5a0074d --- /dev/null +++ b/conf/openstates.php @@ -0,0 +1,5 @@ + diff --git a/index.php b/index.php new file mode 100644 index 0000000..17ba13a --- /dev/null +++ b/index.php @@ -0,0 +1,10 @@ +legislators("state=ma")); + +?> diff --git a/openstates/.openstates.php.swp b/openstates/.openstates.php.swp new file mode 100644 index 0000000..18ca60f Binary files /dev/null and b/openstates/.openstates.php.swp differ diff --git a/openstates/openstates.php b/openstates/openstates.php new file mode 100644 index 0000000..6a2604a --- /dev/null +++ b/openstates/openstates.php @@ -0,0 +1,39 @@ +urlbase . "$fn/?apikey=" . $this->api_key; + foreach ( $args as $key ) { + $query_url .= "&" . $key; + } + return $this->getJSON( $query_url ); + } + + private function getJSON( $URL ) { + $contents = file_get_contents($URL); + $contents = json_decode($contents); + return $contents; + } + + public function __construct($api_key, + $urlbase = "http://openstates.org/api/v1/" + ) { + $this->api_key = $api_key; + $this->urlbase = $urlbase; + } + + public function __call($method, $args) { + if (isset($this->$method) === true) { + $func = $this->$method; + return $func(); + } else { + return $this->queryService($method, $args); + } + } +} + +?>