11504 Génération de la capture d'écran du site

This commit is contained in:
Fred Tempez 2022-06-10 18:40:55 +02:00
parent fe07622042
commit 4716733c34
2 changed files with 12 additions and 3 deletions

View File

@ -257,8 +257,18 @@ class config extends common {
$site = 'https://zwiicms.fr/'; } else { $site = 'https://zwiicms.fr/'; } else {
$site = helper::baseUrl(false); } $site = helper::baseUrl(false); }
$success= false; // Succès de la'opération par défaut
$googlePagespeedData = helper::getUrlContents('https://www.googleapis.com/pagespeedonline/v5/runPagespeed?url='. $site .'&screenshot=true'); $success = false;
// Tente de connecter 5 fois l'API Google
for ($i=0; $i < 5 ; $i++) {
$googlePagespeedData = helper::getUrlContents('https://www.googleapis.com/pagespeedonline/v5/runPagespeed?url='. $site .'&screenshot=true');
if ($googlePagespeedData !== false) {
break;
}
}
// Traitement des données reçues valides.
if ($googlePagespeedData !== false) { if ($googlePagespeedData !== false) {
$googlePagespeedData = json_decode($googlePagespeedData, true); $googlePagespeedData = json_decode($googlePagespeedData, true);
$data = str_replace('_','/',$googlePagespeedData['lighthouseResult']['audits']['final-screenshot']['details']['data']); $data = str_replace('_','/',$googlePagespeedData['lighthouseResult']['audits']['final-screenshot']['details']['data']);

View File

@ -16,7 +16,6 @@
<?php echo template::button('socialMetaImage', [ <?php echo template::button('socialMetaImage', [
'href' => helper::baseUrl() . 'config/configMetaImage', 'href' => helper::baseUrl() . 'config/configMetaImage',
'value' => 'Générer une capture Open Graph' 'value' => 'Générer une capture Open Graph'
]); ?> ]); ?>
</div> </div>
</div> </div>