Google PageSpeed Insights API not working [PHP]

前端 未结 2 377
悲哀的现实
悲哀的现实 2021-01-28 20:17

I\'m a beginner in PHP, so maybe someone could help to fix this ? My web application is showing Google PageInsights API error..

Here\'s the code, I tried to change vers

2条回答
  •  情深已故
    2021-01-28 20:49

    The code shared by Siren Brown is absolutely correct, except that while getting the scores we need to send the query parameter &strategy=mobile or &strategy=desktop to get the respective results from Page speed API

       $url_mobile = 'https://www.googleapis.com/pagespeedonline/v1/runPagespeed?url='.$url.'&screenshot=true&key='.$myKEY.'&strategy=mobile';
       $url_desktop = 'https://www.googleapis.com/pagespeedonline/v1/runPagespeed?url='.$url.'&screenshot=true&key='.$myKEY.'&strategy=desktop';  
    

提交回复
热议问题