PageSpeed api v5 nie działa

0

Witam,
może mi ktoś podpowiedzieć dlaczego ten kod nie działa? Wyświetla tylko pierwszą funkcję a w konsoli pokazuje błąd "Failed to load resource: the server responded with a status of 500 (Internal Server Error)".

function psidesktop() {

$url_desktop ="https://www.googleapis.com/pagespeedonline/v5/runPagespeed?url=https://iqfm.pl&strategy=DESKTOP&key=";

$url_json = file_get_contents($url_desktop);
$url_array = json_decode($url_json, true);

$fcp = $url_array['lighthouseResult']['audits']['first-contentful-paint']['score'];
$si  = $url_array['lighthouseResult']['audits']['speed-index']['score'];
$lcp = $url_array['lighthouseResult']['audits']['largest-contentful-paint']['score'];
$tti = $url_array['lighthouseResult']['audits']['interactive']['score'];
$tbt = $url_array['lighthouseResult']['audits']['total-blocking-time']['score'];
$cls = $url_array['lighthouseResult']['audits']['cumulative-layout-shift']['score'];

$totalscore = (($fcp + $si + $lcp + $tti + $tbt + $cls)/6)*100;
$totalscore = ceil($totalscore);
echo $totalscore;

}
function psimobile() {
$url_mobile ="https://www.googleapis.com/pagespeedonline/v5/runPagespeed?url=https://iqfm.pl&strategy=MOBILE&key=";

$urlm_json = file_get_contents($url_mobile);
$urlm_array = json_decode($urlm_json, true);

$fcpm = $urlm_array['lighthouseResult']['audits']['first-contentful-paint']['score'];
$sim  = $urlm_array['lighthouseResult']['audits']['speed-index']['score'];
$lcpm = $urlm_array['lighthouseResult']['audits']['largest-contentful-paint']['score'];
$ttim = $urlm_array['lighthouseResult']['audits']['interactive']['score'];
$tbtm = $urlm_array['lighthouseResult']['audits']['total-blocking-time']['score'];
$clsm = $urlm_array['lighthouseResult']['audits']['cumulative-layout-shift']['score'];

$totalscorem = (($fcpm + $sim + $lcpm + $ttim + $tbtm + $clsm)/6)*100;
$totalscoremobile = ceil($totalscorem);
echo $totalscoremobile;
}
2

Odpowiedź z api to:

"code": 429,
"message": "Quota exceeded for quota metric 'Queries' and limit 'Queries per minute' of service 'pagespeedonline.googleapis.com' for consumer 'project_number:583797351490'.",
"errors": 

tym samym po przekonwertowaniu tego Jsona do tablicy nie ma w niej kluczy do jakich potem się odwołujesz.
BTW. jesli obie fynkcje różnią się parametrem to warto ten fakt wykorzystać. Możesz ten parametr przekazać do funkcji, a tą wywoływać potem po prostu 2 razy.

1 użytkowników online, w tym zalogowanych: 0, gości: 1