Skip to content
Advertisement

Pagespeed Insights PHP, JSON, CURL Issue?

I’m having a few issues with the Pagespeed API. I’m using CURL to handle the JSON like so:

JavaScript

Outputting the info is fine from the Lighthouse metrics, ie:

JavaScript

But using anything outside Lighthouse I’m having an issue as many keys are hyphenated, ie:

JavaScript

I’ve tried altering the query like:

JavaScript

But can’t get a result or just get a PHP error. I’m probably missing something easy but for the life of me I can’t find it.

Advertisement

Answer

Slightly contrived example…but it shows how to address an object with hyphens in the name.

JavaScript

RESULT

JavaScript

And looking closer at your data i think you got lost somewhere, try

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement