$url = 'https://www.example.com'; $response = eZHTTPTool::getDataByURL($url); echo $response;
$url = 'https://api.example.com/data.json'; $response = eZHTTPTool::getDataByURL($url); $data = json_decode($response); print_r($data);
$url = 'https://www.example.com/nonexistent'; $response = eZHTTPTool::getDataByURL($url); if (!$response) { echo "Error: " . eZHTTPTool::error(); } else { echo $response; }In this example, we're attempting to retrieve a page that doesn't exist (`https://www.example.com/nonexistent`). If the request fails, we're printing the error message using the `error()` method. It's important to note that eZHTTPTool is part of the eZ Publish content management system, but can be used independently. If you're not using eZ Publish, you may need to manually include the library files.