buildRequest('status'); switch($res->getStatusCode()) { case 200: echo 'Successfully connected to the API'; break; case 401: echo 'Failed: Invalid credentials'; break; case 404: echo 'Failed: Please make sure your URL is correct and that there is a trailing slash'; break; default: echo 'Something went wrong... Code: '.$res->getStatusCode(); break; } } public function executeConfig() { $output = ''; $active = 'active'; $artist = ''; $song_title = ''; $res = $this->buildRequest('currentsong'); $array = explode("\n", $res->getBody()); foreach($array as $item) { $item_array = explode(": ", $item); if ($item_array[0] == 'Artist') { $artist = $item_array[1]; } elseif ($item_array[0] == 'Title') { $song_title = $item_array[1]; } } $output = '