* @param string $api_url The API endpoint to use for extraction * @param string $inline_title The

title to use in the HTML * @return string $html_output The formatted HTML result of stories from the API */ function get_stories($api_url, $inline_title) { $response_raw = file_get_contents($api_url); if (is_null($response_raw) || $response_raw == "null") { $html_output .= '

ERROR: Stories not found. API returned `null`.

'; return $html_output; } else { $response = json_decode($response_raw, true); } $html_output = '

' . $inline_title . '

'; for ($i = 0; $i < count($response); $i++) { $sub_url = 'https://hacker-news.firebaseio.com/v0/item/' . $response[$i] . '.json'; $sub_response_raw = file_get_contents($sub_url); $sub_response = json_decode($sub_response_raw, true); $html = '
' . $sub_response['title'] . ''; $html .= '

by '; $html .= $sub_response['by'] . ' | ' . $sub_response['score'] . ' points

'; $html_output .= $html; } return $html_output; } /** *Extract a user's profile from Hacker News API and format in HTML * * @access public * @author cmc * @param string $api_url The API endpoint to use for extraction * @param string $inline_title The

title to use in the HTML * @return string $html_output The formatted HTML result of stories from the API */ function get_user(string $api_url, string $inline_title) { $response_raw = file_get_contents($api_url); if (is_null($response_raw) || $response_raw == "null") { $html_output .= '

ERROR: User not found.

'; return $html_output; } else { $response = json_decode($response_raw, true); } $html_output = '

' . $inline_title . '

'; $html_output .= '

About: ' . $response['about'] . '

'; $html_output .= '

Karma: ' . $response['karma'] . '

'; $html_output .= '

Created: