temp_folder = 'temp/'; $epub->epub_file = $_POST['epub']; $epub->title = $_POST['title']; if ($_POST['cover']) { $coverurl = $_POST['cover']; $coverdata = file_get_contents($coverurl); file_put_contents('temp/cover.jpg', $coverdata); $epub->AddImage( 'temp/cover.jpg', 'image/jpeg', true ); } // cache json in case url expires $tempjsonpath = 'temp/' . hash('md5', $url) . '.json'; $json = ''; if (file_exists($tempjsonpath)) { $json = file_get_contents($tempjsonpath); } else { $json = file_get_contents($url); file_put_contents($tempjsonpath, $json); } $publication = json_decode($json); $content = array_filter($publication->Content, function($item) { return $item->Category == 'Le Monde'; }); usort($content, function ($a, $b) { return $a->PageNumber - $b->PageNumber; }); foreach ($content as $article) { $articlebody = array_filter($article->ContentItem, function($item) { return $item->ContentType == 'text/xml'; })[0]; if ($articlebody->Title && $articlebody->HtmlText) { $pagecontent = '

'. strip_tags($articlebody->Title) . '

'; if ($articlebody->Introduction) { $pagecontent .= '' . $articlebody->Introduction . ''; } $pagecontent .= $articlebody->HtmlText; $epub->AddPage($pagecontent, false, strip_tags($articlebody->Title)); // echo('

'. strip_tags($articlebody->Title) . '

'); // echo($articlebody->HtmlText); } } if ( ! $epub->error ) { $epub->CreateEPUB(); if ( ! $epub->error ) { echo 'Success: Download your book here.'; } } else { echo $epub->error; } } ?>

Go to https://journal.lemonde.fr and hit f12 to get GetPublicationContentItems json and cover jpg urls.

Json url:
Cover url:
Title:
Epub file name: