Trying to parse json request which is quite simple but some how i am not getting my desired result. Following is my json request.
{
"visitorId": "Ow4dLVNXDDqdJ8h3HLqR",
"visits": [{
"requestId": "1679875058704.kTfCKP",
"browserDetails": {
"browserName": "Chrome",
"browserMajorVersion": "111",
"browserFullVersion": "111.0.0",
"os": "Windows",
"osVersion": "10",
"device": "Other",
"userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36"
},
"incognito": false,
"ip": "81.21.0.107",
"ipLocation": {
"accuracyRadius": 100,
"latitude": 52.153,
"longitude": -2.637,
"postalCode": "DE02",
"timezone": "Europe/London",
"city": {
"name": "COnset"
},
"country": {
"code": "GB",
"name": "United Kingdom"
},
"continent": {
"code": "EU",
"name": "Europe"
},
"subdivisions": [{
"isoCode": "ENG",
"name": "England"
}, {
"isoCode": "GAT",
"name": "Consent"
}]
},
"timestamp": 1679875058729,
"time": "2023-03-26T23:57:38Z",
"url": "https://searchdaily.org/",
"tag": {},
"confidence": {
"score": 1
},
"visitorFound": true,
"firstSeenAt": {
"global": "2023-02-20T17:56:09.517Z",
"subscription": "2023-03-22T17:11:51.102Z"
},
"lastSeenAt": {
"global": "2023-03-26T23:56:55.108Z",
"subscription": "2023-03-26T23:56:55.108Z"
}
}],
"lastTimestamp": 1679875058704,
"paginationKey": "1679875058704.kTfCKP"
}
Here is my PHP code which i am using to parse particular node "visits->confidence->score"
<?php
$url="https://api.fpjs.io/visitors/s22jsdjjj24?api_key=asdkjk232asdk&limit=1";
$data=file_get_contents($url);
$json=json_decode($data);
echo $json->visits->confidence->score;
?>
it returns me a blank value I know is missing a tiny part. Any help will be appreciated. thanks