commit 8390f7a11bee3cc6d798414471a0d3b89ac1fc0a parent 300abd43f21e02aa39da32221274dddafcbae1f1 Author: Gerco van Woudenbergh <[email protected]> Date: Wed, 28 Jun 2023 15:32:01 +0200 connecting to api Diffstat:
M | Controller/api/api.php | 8 | +++++--- |
M | Model/Connect.php | 8 | +------- |
2 files changed, 6 insertions(+), 10 deletions(-)
diff --git a/Controller/api/api.php b/Controller/api/api.php @@ -2,7 +2,9 @@ $test = function(&$vars){ $token = '3jvl/yb?sRr80s6lTdeOyxV9VTQZkCPRp/bKOWKFWxfL2vhsU4Hhpgcmz9qe0zEk'; $url = 'http://86.92.67.21/api/windchill'; - $connect = new Model\Connect($url, $token); - $connect->connect(); - var_dump($connect->get_response()); + $connect = new Model\Connect($url, $token); + $response = $connect->connect(); + foreach($response as $obj){ + echo "city " . $obj->city . " windchill corrected:" . $obj->windchill . "<br>"; + } }; \ No newline at end of file diff --git a/Model/Connect.php b/Model/Connect.php @@ -33,13 +33,7 @@ namespace Model{ curl_close($ch); - $this->json = $response; - } - function response(){ - return json_decode($this->json); - } - function get_response():string{ - return $this->json; + return json_decode($response); } } } \ No newline at end of file