*/ function GetApiResults(string $api_url): mixed { $response = file_get_contents($api_url); return json_decode($response, true); } /** * Formats a given set of API results into an HTML section * * @access public * @param mixed $api_results The decoded API results * @param string $inline_title The
ERROR: Stories not found. API returned `null`.
'; } else { $html_output = 'ERROR: User not found.
'; } else { // TODO: Create function to format $about using the following guidelines // : https://news.ycombinator.com/formatdoc // : hint: nl2br() will solve the first formatting requirement $about = $api_results['about']; $karma = $api_results['karma']; $created = date('Y-m-d h:m:s', $api_results['created']); $html_output = <<About: $about
Karma: $karma
Created:
User has no submissions.
'; } return $html_output; } } /** * Formats one specific item requested by the user * * @access public * @param mixed $api_results The decoded API results * @param string $inline_title Theby $by | $score points | $descendants comments
EOT; } /** * Creates a story discussion page with comments * * @access public * @return string The formatted HTML result of stories from the API or the error message * @author cmc$text
Submitted in response to: $parent
EOT; } /** * Creates a poll HTML element * * @access public * @param mixed $api_results The decoded API results * @return string The formatted HTML result of stories from the API or the error message * @author cmc