/
home
/
faureele
/
extra-til
/
wp-content
/
themes
/
woffice-child-theme
/
api-til
/
Upload File
HOME
<?php // requête affichant les articles publiées sur le site www.just-carsregion.fr require 'HTTP/Request2.php'; $requestArticle=new HTTP_Request2(); // $requestArticle->setUrl('https://www.just-carsregion.fr/wp-json/wp/v2/posts?categories=10'); $requestArticle->setUrl('https://www.just-carsregion.fr/wp-json/wp/v2/posts'); $requestArticle->setMethod(HTTP_Request2::METHOD_GET); $requestArticle->setConfig(array( 'follow_redirects' => TRUE )); // $requestArticle->setHeader(array( // 'Authorization' => 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwczpcL1wvd3d3Lmp1c3QtdGlsLmZyIiwiaWF0IjoxNjAwMDg4OTEzLCJuYmYiOjE2MDAwODg5MTMsImV4cCI6MTYwMDY5MzcxMywiZGF0YSI6eyJ1c2VyIjp7ImlkIjoiMyJ9fX0.XldYv-RrwlNL_79-RWIcaI8Ug_nMNrSHQpxA-qihbsU', // 'Cookie' => 'Cookie_1=value; PHPSESSID=b0abd763867762d743ccd4da192171aa' // )); $requestArticle->setHeader(array( 'Cookie' => 'Cookie_1=value; PHPSESSID=6f380b5331c9d668cf62723e071b73e5' )); try{ $responseArticles=$requestArticle->send(); if($responseArticles->getStatus() == 200){ $resultArticles = $responseArticles->getBody(); $resultArticlesDecode=json_decode($resultArticles, true); // echo "<div class='container'><div class='row'>"; echo "<div id='content'><div id='directory' class='masonry-layout masonry-layout--3-columns' style='position: relative; height: 479.133px;'>"; foreach($resultArticlesDecode as $article){ $imageSrc = $article['featured_image_src']; $title = $article['title']['rendered']; $dateModif = $article['modified']; $datePubliee = date("d-m-Y H:i:s", strtotime($dateModif)); $excerpt = $article['excerpt']['rendered']; $link = $article['link']; $category=array($article['categories']); echo " <div class='box blog-item' style='position: absolute; left: 0px; top: 0px; border:1px solid #cecece; '> <div class='intern-thumbnail' style='margin-bottom: -25px !important;'> <a href='".$link."' target='_blank'> <picture> <source srcset='".$imageSrc."' media='(min-width: 1920px)'> <img src='".$imageSrc."' /> </picture> </a> </div> <div class='intern-padding' style='margin-bottom: -55px !important;'> <div class='intern-box box-title' style='margin-bottom:-35px !important; margin-top:10px !important;'> <h3> <a href='".$link."'>".$title."</a> </h3> <br> <span class='post-date directory-comments'> <i class='fa fa-clock'></i> ".$datePubliee." </span> </div> <div> <p>".$excerpt."</p> </div> </div> <div class='intern-box text-center'> <a href='".$link."' target='_blank' class='btn btn-default mb-0'><i class='fa fa-arrow-right'></i> Lire plus</a> </div> </div> "; } echo "</div></div>"; }else{ echo 'Unexpected HTTP status: ' . $responseArticles->getStatus() . ' ' . $responseArticles->getReasonPhrase(); } }catch(HTTP_Request2_Exception $e) { echo 'Error: ' . $e->getMessage(); }