Phrasing Json response in PHP - php

So I have come to a slight issue in phrasing this api response.
I'm trying to phrase the screenshot data from this api response?..
I have tried the below but to no avail!.. It just seems to be NULL?..
any help would be great thanks
$jsonData = json_decode($response, true);
$testt = $jsonData->screenshot->data;
The response:
{
"kind": "pagespeedonline#result",
"id": "http://stackoverflow.com/",
"responseCode": 200,
"title": "Stack Overflow",
"score": 78,
"pageStats": {
"numberResources": 31,
"numberHosts": 11,
"totalRequestBytes": "4412",
"numberStaticResources": 22,
},
"formattedResults": {
"locale": "en_US",
"ruleResults": {
"AvoidLandingPageRedirects": {
"localizedRuleName": "Avoid landing page redirects",
"ruleImpact": 0.0,
"urlBlocks": [
{
"header": {
"format": "Your page has no redirects. Learn more about avoiding landing page redirects.",
"args": [
{
"type": "HYPERLINK",
"value": "https://developers.google.com/speed/docs/insights/AvoidRedirects"
}
]
}
}
]
},
"EnableGzipCompression": {
"localizedRuleName": "Enable compression",
"ruleImpact": 0.0,
"urlBlocks": [
{
"header": {
"format": "You have compression enabled. Learn more about enabling compression.",
"args": [
{
"type": "HYPERLINK",
"value": "https://developers.google.com/speed/docs/insights/EnableCompression"
}
]
}
}
]
},
"LeverageBrowserCaching": {
"localizedRuleName": "Leverage browser caching",
"ruleImpact": 0.0,
"urlBlocks": [
{
"header": {
"format": "You have enabled browser caching. Learn more about browser caching recommendations.",
"args": [
{
"type": "HYPERLINK"
}
]
}
}
]
},
"MainResourceServerResponseTime": {
"localizedRuleName": "Reduce server response time",
"ruleImpact": 0.0,
"urlBlocks": [
{
"header": {
"format": "Your server responded quickly. Learn more about server response time optimization.",
"args": [
{
"type": "HYPERLINK",
"value": "https://developers.google.com/speed/docs/insights/Server"
}
]
}
}
]
},
"MinifyCss": {
"localizedRuleName": "Minify CSS",
"ruleImpact": 0.0,
"urlBlocks": [
{
"header": {
"format": "Your CSS is minified. Learn more about minifying CSS.",
"args": [
{
"value": "https://developers.google.com/speed/docs/insights/MinifyResources"
}
]
}
}
]
},
"MinifyHTML": {
"ruleImpact": 0.1443,
"urlBlocks": [
{
"header": {
"format": "Compacting HTML code, including any inline JavaScript and CSS contained in it, can save many bytes of data and speed up download and parse times."
}
},
{
"header": {
"format": "Minify HTML for the following resources to reduce their size by $2 ($3 reduction).",
"args": [
{
"value": "https://developers.google.com/speed/docs/insights/MinifyResources"
},
{
"value": "1.4KiB"
},
{
"value": "5%"
}
]
},
"urls": [
{
"result": {
"format": "Minifying $1 could save $2 ($3 reduction) after compression.",
"args": [
{
"type": "URL",
"value": "http://stackoverflow.com/"
},
{
"type": "BYTES",
"value": "1.4KiB"
},
{
"value": "5%"
}
]
}
}
]
}
]
},
"MinifyJavaScript": {
"localizedRuleName": "Minify JavaScript",
"ruleImpact": 0.0,
"urlBlocks": [
{
"header": {
"format": "Your JavaScript content is minified. Learn more about minifying JavaScript.",
"args": [
{
"type": "HYPERLINK",
"value": "https://developers.google.com/speed/docs/insights/MinifyResources"
}
]
}
}
]
},
"MinimizeRenderBlockingResources": {
"localizedRuleName": "Eliminate render-blocking JavaScript and CSS in above-the-fold content",
"urlBlocks": [
{
"header": {
"args": [
{
"type": "INT_LITERAL",
"value": "2"
},
{
"type": "INT_LITERAL",
"value": "3"
}
]
}
},
{
"header": {
"format": "None of the above-the-fold content on your page could be rendered without waiting for the following resources to load. Try to defer or asynchronously load blocking resources, or inline the critical portions of those resources directly in the HTML."
}
},
{
"header": {
"args": [
{
"type": "HYPERLINK",
"value": "https://developers.google.com/speed/docs/insights/BlockingJS"
}
]
},
"urls": [
{
"result": {
"format": "$1",
"args": [
{
"type": "URL",
"value": "http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"
}
]
}
},
{
"result": {
"format": "$1",
"args": [
{
"type": "URL",
"value": "http://cdn.sstatic.net/Js/stub.en.js?v=174f553de1d0"
}
]
}
}
]
},
{
"header": {
"format": "Optimize CSS Delivery of the following:",
"args": [
{
"type": "HYPERLINK",
"value": "https://developers.google.com/speed/docs/insights/OptimizeCSSDelivery"
}
]
},
"urls": [
{
"result": {
"format": "$1",
"args": [
{
"type": "URL",
"value": "http://cdn.sstatic.net/stackoverflow/all.css?v=55bbe6171ff2"
}
]
}
},
{
"result": {
"format": "$1",
"args": [
{
"type": "URL",
"value": "http://cdn-careers.sstatic.net/careers/gethired/company.min.css?v=86ee8c8bfa3e"
}
]
}
},
{
"result": {
"format": "$1",
"args": [
{
"type": "URL",
"value": "http://cdn-careers.sstatic.net/careers/gethired/sidebar.min.css?v=88f3fd5e2263"
}
]
}
}
]
}
]
},
"OptimizeImages": {
"localizedRuleName": "Optimize images",
"ruleImpact": 3.0802000000000005,
"urlBlocks": [
{
"header": {
"format": "Properly formatting and compressing images can save many bytes of data."
}
},
{
"header": {
"format": "Optimize the following images to reduce their size by $2 ($3 reduction).",
"args": [
{
"type": "HYPERLINK",
"value": "https://developers.google.com/speed/docs/insights/OptimizeImages"
},
{
"type": "BYTES",
"value": "30KiB"
},
{
"type": "PERCENTAGE",
"value": "42%"
}
]
},
"urls": [
{
"result": {
"format": "Losslessly compressing $1 could save $2 ($3 reduction).",
"args": [
{
"type": "URL",
"value": "http://cdn-careers.sstatic.net/careers/gethired/img/careers4-ad-header-so-crop.png?v=f4ca4345dc81"
},
{
"type": "BYTES",
"value": "16.6KiB"
},
{
"type": "PERCENTAGE",
"value": "73%"
}
]
}
},
{
"result": {
"format": "Losslessly compressing $1 could save $2 ($3 reduction).",
"args": [
{
"type": "URL",
"value": "http://cdn.sstatic.net/img/share-sprite-new.png?v=204b1e0e421b"
},
{
"type": "BYTES",
"value": "2.9KiB"
},
{
"type": "PERCENTAGE",
"value": "19%"
}
]
}
},
{
"result": {
"format": "Losslessly compressing $1 could save $2 ($3 reduction).",
"args": [
{
"type": "URL",
"value": "http://cdn.sstatic.net/Img/sprite-herobox.png?v=d173774f3a9f"
},
{
"type": "BYTES",
"value": "2.8KiB"
},
{
"type": "PERCENTAGE",
"value": "43%"
}
]
}
},
{
"result": {
"format": "Losslessly compressing $1 could save $2 ($3 reduction).",
"args": [
{
"type": "URL",
"value": "http://i.stack.imgur.com/Tfe0K.png"
},
{
"type": "BYTES",
"value": "2.6KiB"
},
{
"type": "PERCENTAGE",
"value": "76%"
}
]
}
},
{
"result": {
"format": "Losslessly compressing $1 could save $2 ($3 reduction).",
"args": [
{
"type": "URL",
"value": "http://i.stack.imgur.com/vobok.png"
},
{
"type": "BYTES",
"value": "2.6KiB"
},
{
"type": "PERCENTAGE",
"value": "76%"
}
]
}
},
{
"result": {
"format": "Losslessly compressing $1 could save $2 ($3 reduction).",
"args": [
{
"type": "URL",
"value": "http://cdn.sstatic.net/stackoverflow/img/sprites.png?v=3c6263c3453b"
},
{
"type": "BYTES",
"value": "1.5KiB"
},
{
"type": "PERCENTAGE",
"value": "9%"
}
]
}
},
{
"result": {
"format": "Losslessly compressing $1 could save $2 ($3 reduction).",
"args": [
{
"type": "URL",
"value": "http://i.stack.imgur.com/G1dzB.png"
},
{
"type": "BYTES",
"value": "962B"
},
{
"type": "PERCENTAGE",
"value": "50%"
}
]
}
}
]
}
]
},
"PrioritizeVisibleContent": {
"localizedRuleName": "Prioritize visible content",
"ruleImpact": 2.0,
"urlBlocks": [
{
"header": {
"format": "Your page requires additional network round trips to render the above-the-fold content. For best performance, reduce the amount of HTML needed to render above-the-fold content."
}
},
{
"header": {
"format": "The entire HTML response was not sufficient to render the above-the-fold content. This usually indicates that additional resources, loaded after HTML parsing, were required to render above-the-fold content. Prioritize visible content that is needed for rendering above-the-fold by including it directly in the HTML response.",
"args": [
{
"type": "HYPERLINK",
"value": "https://developers.google.com/speed/docs/insights/PrioritizeVisibleContent"
}
]
},
"urls": [
{
"result": {
"format": "Only about $1 of the final above-the-fold content could be rendered with the full HTML response $2.",
"args": [
{
"type": "PERCENTAGE",
"value": "26%"
},
{
"type": "SNAPSHOT_RECT",
"value": "snapshot:5"
}
]
}
}
]
}
]
}
}
},
"version": {
"major": 1,
"minor": 15
},
"screenshot": {
"data": "***************8This is the data i need!!*********",
"height": 240,
"mime_type": "image/jpeg",
"width": 320
}
}

You set the assoc Parameter in json_decode on true, so it will return an array!
You just have to delete true like this:
$jsonData = json_decode($response);
$testt = $jsonData->screenshot->data;
Of course you can change true to false aswell:
$jsonData = json_decode($response, false);
$testt = $jsonData->screenshot->data;
More information about this in the PHP-Manual for json_decode

use it like
$jsonData = json_decode($aa, true);
echo $jsonData['screenshot']['data'];
working code

First, there is an error in your JSON on line 11 that stops json_deocde() returning a valid array (you should remove the trailing comma):
"numberStaticResources": 22,
Second, you are getting an array from json_decode() so you need to use the correct syntax:
$jsonData = json_decode($response, true);
$testt = $jsonData['screenshot']['data'];

Related

Elasticsearch batch not indexing all items using PHP client

I've been trying to build an index in ES and add the initial items to it (around 350k), using PHP.
I tried all kinds of batch sizes (from 10 items to 1k), check the count, check the threshold, but for some reason it doesn't index every item.
It just skips over some random items, without any errors in the batch result response. I feel like I tried everything and I have to idea what to do next
I'm using Amazon OpenSearch with the latest supported ES (7.10).
The index looks like this:
{
"wonder-search": {
"aliases": {},
"mappings": {
"properties": {
"address": {
"type": "text"
},
"city": {
"type": "text"
},
"city_id": {
"type": "integer"
},
"duration": {
"type": "integer"
},
"filename": {
"type": "text"
},
"geo_point": {
"type": "geo_point"
},
"icon": {
"type": "keyword"
},
"is_sandbox": {
"type": "integer"
},
"item_id": {
"type": "integer"
},
"item_label": {
"type": "keyword"
},
"latitude": {
"type": "float"
},
"longitude": {
"type": "float"
},
"search_text_caption_json": {
"type": "text",
"index_phrases": true
},
"search_text_city_json": {
"type": "text",
"index_phrases": true
},
"search_text_completion": {
"type": "completion",
"analyzer": "simple",
"preserve_separators": true,
"preserve_position_increments": true,
"max_input_length": 50,
"contexts": [
{
"name": "type",
"type": "CATEGORY"
}
]
},
"search_text_country_json": {
"type": "text",
"index_phrases": true
},
"search_text_cuisine_name_json": {
"type": "text",
"index_phrases": true
},
"search_text_location_name_json": {
"type": "text",
"index_phrases": true
},
"search_text_state_json": {
"type": "text",
"index_phrases": true
},
"search_text_tag_name_json": {
"type": "text",
"index_phrases": true
},
"search_text_username_json": {
"type": "text",
"index_phrases": true
},
"sort": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"sort_score": {
"type": "double"
},
"type": {
"type": "text"
},
"user_icon": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"user_id": {
"type": "integer"
},
"username": {
"type": "keyword"
},
"vanity_url": {
"type": "keyword"
},
"video_count": {
"type": "integer"
}
}
},
"settings": {
"index": {
"routing": {
"allocation": {
"include": {
"_tier_preference": "data_content"
}
}
},
"mapping": {
"ignore_malformed": "true"
},
"number_of_shards": "1",
"provided_name": "wonder-search",
"creation_date": "1671003076106",
"number_of_replicas": "1",
"uuid": "YQh1q40WTneLE4MWDWhArw",
"version": {
"created": "7100199"
}
}
}
}
}
and one item looks like this:
{
"_index": "wonder-search",
"_type": "_doc",
"_id": "wq2LD4UBUAuy7FQPhtZh",
"_version": 1,
"_seq_no": 2003,
"_primary_term": 1,
"found": true,
"_source": {
"sort": "4004",
"item_id": "4934",
"user_id": "434",
"user_icon": "/site-content/avatars/Sp8AXjTJvMbRao2oZbuiUuSVH042-1597776099045.jpeg",
"username": "chuurros",
"item_label": "Kyoto Katsugyu【京都勝牛】",
"search_text_username_json": [
"chuurros"
],
"search_text_caption_json": [
"Absolutely love their gyukatsu (beef katsu) here! Delicious and will keep you wanting more! 🥰"
],
"search_text_city_json": [
"Toronto"
],
"search_text_state_json": [
"Ontario"
],
"search_text_country_json": [
"Canada"
],
"search_text_location_name_json": [
"Kyoto Katsugyu【京都勝牛】"
],
"search_text_tag_name_json": [
"japanese",
"restaurant",
"asian",
"dining",
"topcollection-4934"
],
"search_text_cuisine_name_json": [],
"type": "video",
"vanity_url": "",
"icon": "",
"city": "Toronto",
"city_id": "439",
"latitude": "43.65682410",
"longitude": "-79.37617410",
"address": "134 Dundas St E",
"duration": "9.57",
"video_count": "0",
"sort_score": "43",
"filename": "373d75fd-4292-4e5b-a239-4b1c39ffc86c.MOV",
"is_sandbox": "0",
"geo_point": {
"lat": "43.65682410",
"lon": "-79.37617410"
},
"search_text_completion": {
"input": [
"Kyoto Katsugyu【京都勝牛】"
],
"contexts": {
"type": [
"video"
]
}
}
}
}
Any ideas why does it work like this?

Extract element from nested JSON

There is json response:
{
"id": "1234567890123456789",
"creation_date": 12345678,
"event": "WAITING_PAYMENT",
"version": "2.0.0",
"data": {
"product": {
"id": 213344,
"name": "Product Name",
"has_co_production": false
},
"affiliates": [
{
"name": "Affiliate name"
}
],
"buyer": {
"email": "buyer#email.com"
},
"producer": {
"name": "Producer Name"
},
"commissions": [
{
"value": 0.65,
"source": "MARKETPLACE"
},
{
"value": 3.10,
"source": "PRODUCER"
}
],
"purchase": {
"approved_date": 1231241434453,
"full_price": {
"value": 134.0
},
"original_offer_price": {
"currency_value": "EUR"
"value": 100.78,
},
"price": {
"value": 150.6
},
"order_date": "123243546",
"status": "STARTED",
"transaction": "HP02316330308193",
"payment": {
"billet_barcode": "03399.33335 33823.303087 198801027 2 876300015000",
"billet_url": "https://billet-link.com/bHP023163303193",
}
},
"subscription": {
"status": "ACTIVE",
"plan": {
"name": "plan name"
},
"subscriber": {
"code": "12133421"
}
}
}
}
My question is how to extract data["buyer"]["email"] in PHP ?
I only need to extract the email information from the buyer table inside the data table.
First, you need to decode the json to a PHP array (or an object), then you can access the requested information from the decoded data.
$data = json_decode('the json string most place here', true);
$email = $data['buyer']['email'];
Place your json string in the first argument of json_decode() function.

Wordpress 401 error: rest_forbidden. Sorry, you are not allowed to make proxied oEmbed requests

I'm getting 401 error on the following URL call on my Wordpress hosted on Windows IIS server:
https://example.com/wp-json/oembed/1.0/proxy?url=https://example.com/wp-content/uploads/img.jpg
{
"code": "rest_forbidden",
"message": "Sorry, you are not allowed to make proxied oEmbed requests.",
"data": {
"status": 401
}
}
The above URL is called by the Elementor gallery widget when I want to set an external image for it.
Although, the following URL is working on my Wordpress site:
https://example.com/wp-json/oembed/1.0?url=https://example.com/wp-content/uploads/img.jpg
{
"namespace": "oembed\/1.0",
"routes": {
"\/oembed\/1.0": {
"namespace": "oembed\/1.0",
"methods": ["GET"],
"endpoints": [{
"methods": ["GET"],
"args": {
"namespace": {
"default": "oembed\/1.0",
"required": false
},
"context": {
"default": "view",
"required": false
}
}
}
],
"_links": {
"self": [{
"href": "https:\/\/example.com\/wp-json\/oembed\/1.0"
}
]
}
},
"\/oembed\/1.0\/embed": {
"namespace": "oembed\/1.0",
"methods": ["GET"],
"endpoints": [{
"methods": ["GET"],
"args": {
"url": {
"description": "The URL of the resource for which to fetch oEmbed data.",
"type": "string",
"format": "uri",
"required": true
},
"format": {
"default": "json",
"required": false
},
"maxwidth": {
"default": 600,
"required": false
}
}
}
],
"_links": {
"self": [{
"href": "https:\/\/example.com\/wp-json\/oembed\/1.0\/embed"
}
]
}
},
"\/oembed\/1.0\/proxy": {
"namespace": "oembed\/1.0",
"methods": ["GET"],
"endpoints": [{
"methods": ["GET"],
"args": {
"url": {
"description": "The URL of the resource for which to fetch oEmbed data.",
"type": "string",
"format": "uri",
"required": true
},
"format": {
"description": "The oEmbed format to use.",
"type": "string",
"default": "json",
"enum": ["json", "xml"],
"required": false
},
"maxwidth": {
"description": "The maximum width of the embed frame in pixels.",
"type": "integer",
"default": 600,
"required": false
},
"maxheight": {
"description": "The maximum height of the embed frame in pixels.",
"type": "integer",
"required": false
},
"discover": {
"description": "Whether to perform an oEmbed discovery request for unsanctioned providers.",
"type": "boolean",
"default": true,
"required": false
}
}
}
],
"_links": {
"self": [{
"href": "https:\/\/example.com\/wp-json\/oembed\/1.0\/proxy"
}
]
}
}
},
"_links": {
"up": [{
"href": "https:\/\/example.com\/wp-json\/"
}
]
}
}
PHP: 7.4.16
Wordpress: 5.6.2
Windows Server: 2019

ElasticSearch returning no results despite correct query

I have created an index named filebeat in elasticsearch.The log data is being sent in elasticsearch by filebeat agent.
I want to filter the results based on a particular column/field named value_of_type. Using PHP API :
$json =
'{
"query" : {
"bool" : {
"filter": [
{
"term" :
{
"value_of_type" : "sound"
}
}
]
}
}
}';
But its returning 0 results.
{"took":4,"timed_out":false,"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":0,"max_score":null,"hits":[]}}
The result of hitting myurl:9200/filebeat in browser looks like this :
{
"filebeat": {
"aliases": {},
"mappings": {
"doc": {
"properties": {
"#timestamp": {
"type": "date"
},
"beat": {
"properties": {
"hostname": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"name": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"version": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
},
"fields": {
"properties": {
"node": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"value_of_type": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
},
"input_type": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"message": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"offset": {
"type": "long"
},
"source": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"type": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
}
},
"settings": {
"index": {
"creation_date": "1494116541083",
"number_of_shards": "5",
"number_of_replicas": "1",
"uuid": "IdhWgIqiQ-GNrZK3AvCP9g",
"version": {
"created": "5020199"
},
"provided_name": "filebeat"
}
}
}
}
Your query is correct, but it doesn't match anything in the index: the documents you have indexed don't have the correct structure.
For you query to match a document, documents in your index should have a value_of_type field with value "sound" (like returned in the sample response below.)
A simple GET /filebeat/_search query (without any filter) should give a result like this:
{
"took": 28,
"timed_out": false,
"hits": {
"total": N, // the number of documents in your index
"max_score": 1,
"hits": [
...
{
"_index": "filebeat",
"_type": "some_doc_type",
"_id": "some_id",
"_score": 1,
"_source": {
...
"value_of_type": "sound", // that's what you query will match
...
}
]
}

How can i retrieve google page speed score using curl

Upon reading google page speed api developer's guide
i would like to retrieve page speed score using curl or whatever can retrieve it from the output
Here should be the link i'm going to use (i only needs score "score": 97 cause i will store it in database)
https://www.googleapis.com/pagespeedonline/v1/runPagespeed?url=http://www.my_site.com&key={MY API KEY}
it will gives the following results
{
"kind": "pagespeedonline#result",
"request": {
"url": "http://www.my___site.com"
},
"id": "http://www.my___site.com/",
"responseCode": 404,
"title": "404 Error - Page Not Found",
"score": 97,
"pageStats": {
"numberResources": 19,
"numberHosts": 11,
"totalRequestBytes": "4982",
"numberStaticResources": 10,
"htmlResponseBytes": "67960",
"cssResponseBytes": "11318",
"imageResponseBytes": "20824",
"javascriptResponseBytes": "200855",
"otherResponseBytes": "52076",
"numberJsResources": 6,
"numberCssResources": 2
},
"formattedResults": {
"locale": "en_US",
"ruleResults": {
"AvoidLandingPageRedirects": {
"localizedRuleName": "Avoid landing page redirects",
"ruleScore": 100,
"ruleImpact": 0.0,
"urlBlocks": [
{
"header": {
"format": "Your page has no redirects. Learn more about avoiding landing page redirects.",
"args": [
{
"type": "HYPERLINK",
"value": "https://developers.google.com/speed/docs/insights/AvoidRedirects"
}
]
}
}
]
},
"EnableGzipCompression": {
"localizedRuleName": "Enable compression",
"ruleScore": 100,
"ruleImpact": 0.0,
"urlBlocks": [
{
"header": {
"format": "You have compression enabled. Learn more about enabling compression.",
"args": [
{
"type": "HYPERLINK",
"value": "https://developers.google.com/speed/docs/insights/EnableCompression"
}
]
}
}
]
},
"LeverageBrowserCaching": {
"localizedRuleName": "Leverage browser caching",
"ruleScore": 90,
"ruleImpact": 0.49702380952380953,
"urlBlocks": [
{
"header": {
"format": "Setting an expiry date or a maximum age in the HTTP headers for static resources instructs the browser to load previously downloaded resources from local disk rather than over the network."
}
},
{
"header": {
"format": "Leverage browser caching for the following cacheable resources:",
"args": [
{
"type": "HYPERLINK",
"value": "https://developers.google.com/speed/docs/insights/LeverageBrowserCaching"
}
]
},
"urls": [
{
"result": {
"format": "$1 ($2)",
"args": [
{
"type": "URL",
"value": "http://www.google.com/adsense/domains/caf.js"
},
{
"type": "DURATION",
"value": "60 minutes"
}
]
}
}
]
}
]
},
"MainResourceServerResponseTime": {
"localizedRuleName": "Reduce server response time",
"ruleScore": 100,
"ruleImpact": 0.0,
"urlBlocks": [
{
"header": {
"format": "Your server responded quickly. Learn more about server response time optimization.",
"args": [
{
"type": "HYPERLINK",
"value": "https://developers.google.com/speed/docs/insights/Server"
}
]
}
}
]
},
"MinifyCss": {
"localizedRuleName": "Minify CSS",
"ruleScore": 100,
"ruleImpact": 0.0,
"urlBlocks": [
{
"header": {
"format": "Your CSS is minified. Learn more about minifying CSS.",
"args": [
{
"type": "HYPERLINK",
"value": "https://developers.google.com/speed/docs/insights/MinifyResources"
}
]
}
}
]
},
"MinifyHTML": {
"localizedRuleName": "Minify HTML",
"ruleScore": 94,
"ruleImpact": 0.2277,
"urlBlocks": [
{
"header": {
"format": "Compacting HTML code, including any inline JavaScript and CSS contained in it, can save many bytes of data and speed up download and parse times."
}
},
{
"header": {
"format": "Minify HTML for the following resources to reduce their size by $2 ($3 reduction).",
"args": [
{
"type": "HYPERLINK",
"value": "https://developers.google.com/speed/docs/insights/MinifyResources"
},
{
"type": "BYTES",
"value": "2.1KiB"
},
{
"type": "PERCENTAGE",
"value": "9%"
}
]
},
"urls": [
{
"result": {
"format": "Minifying $1 could save $2 ($3 reduction) after compression.",
"args": [
{
"type": "URL",
"value": "http://dsnextgen.com/?domainname=www.my___site.com&a_id=101686&session_token=undefined"
},
{
"type": "BYTES",
"value": "2.1KiB"
},
{
"type": "PERCENTAGE",
"value": "9%"
}
]
}
}
]
}
]
},
"MinifyJavaScript": {
"localizedRuleName": "Minify JavaScript",
"ruleScore": 100,
"ruleImpact": 0.0,
"urlBlocks": [
{
"header": {
"format": "Your JavaScript content is minified. Learn more about minifying JavaScript.",
"args": [
{
"type": "HYPERLINK",
"value": "https://developers.google.com/speed/docs/insights/MinifyResources"
}
]
}
}
]
},
"MinimizeRenderBlockingResources": {
"localizedRuleName": "Eliminate render-blocking JavaScript and CSS in above-the-fold content",
"ruleScore": 100,
"ruleImpact": 2.0,
"urlBlocks": [
{
"header": {
"format": "Your page has $1 blocking script resources. This causes a delay in rendering your page.",
"args": [
{
"type": "INT_LITERAL",
"value": "2"
}
]
}
},
{
"header": {
"format": "None of the above-the-fold content on your page could be rendered without waiting for the following resources to load. Try to defer or asynchronously load blocking resources, or inline the critical portions of those resources directly in the HTML."
}
},
{
"header": {
"format": "Remove render-blocking JavaScript:",
"args": [
{
"type": "HYPERLINK",
"value": "https://developers.google.com/speed/docs/insights/BlockingJS"
}
]
},
"urls": [
{
"result": {
"format": "$1",
"args": [
{
"type": "URL",
"value": "http://pagead2.googlesyndication.com/apps/domainpark/show_afd_ads.js"
}
]
}
},
{
"result": {
"format": "$1",
"args": [
{
"type": "URL",
"value": "http://googleads.g.doubleclick.net/apps/domainpark/domainpark.cgi?callback=_google_json_callback&output=js&client=ca-dp-oversee_ncd&domain_name=www.my___site.com&st=create&s=www.my___site.com&dt=1381663474340&u_tz=-420&u_his=1&u_h=768&u_w=1024&frm=0"
}
]
}
}
]
}
]
},
"OptimizeImages": {
"localizedRuleName": "Optimize images",
"ruleScore": 100,
"ruleImpact": 0.0,
"urlBlocks": [
{
"header": {
"format": "Your images are optimized. Learn more about optimizing images.",
"args": [
{
"type": "HYPERLINK",
"value": "https://developers.google.com/speed/docs/insights/OptimizeImages"
}
]
}
}
]
},
"PrioritizeVisibleContent": {
"localizedRuleName": "Prioritize visible content",
"ruleScore": 100,
"ruleImpact": 0.0,
"urlBlocks": [
{
"header": {
"format": "You have the above-the-fold content properly prioritized. Learn more about prioritizing visible content.",
"args": [
{
"type": "HYPERLINK",
"value": "https://developers.google.com/speed/docs/insights/PrioritizeVisibleContent"
}
]
}
}
]
}
}
},
"version": {
"major": 1,
"minor": 14
}
}
thanks for helping me
It's in JSON, so you need to json_decode it first.
$json = json_decode($data);
echo $json->score;

Categories