i work on project, where there are server that send to my php application json data and then i put it in database. I receive a POST request from the server and i can get json with this : receive_json.php:
$payload = file_get_contents('php://input');
and there is the form of the JSON:
{
"applicationID": "123",
"applicationName": "temperature-sensor",
"deviceName": "garden-sensor",
"devEUI": "0202020202020202",
"rxInfo": [
{
"gatewayID": "0303030303030303", // ID of the receiving gateway
"name": "rooftop-gateway", // name of the receiving gateway
"time": "2016-11-25T16:24:37.295915988Z", // time when the package was received (GPS time of gateway, only set when available)
"rssi": -57, // signal strength (dBm)
"loRaSNR": 10, // signal to noise ratio
"location": {
"latitude": 52.3740364, // latitude of the receiving gateway
"longitude": 4.9144401, // longitude of the receiving gateway
"altitude": 10.5, // altitude of the receiving gateway
}
}
],
"txInfo": {
"frequency": 868100000, // frequency used for transmission
"dr": 5 // data-rate used for transmission
},
"adr": false, // device ADR status
"fCnt": 10, // frame-counter
"fPort": 5, // FPort
"data": "...", // base64 encoded payload (decrypted)
"object": { // decoded object (when application coded has been configured)
"temperatureSensor": {"1": 25},
"humiditySensor": {"1": 32}
}
}
i'm new user of JSON, so i put directly the text JSON to my database like this :
$payload = file_get_contents('php://input');
$req = $bdd->prepare( '
INSERT INTO nods(payload)
VALUES (:payload);
' );
$req->execute(array('payload' => $payload));
the result :
I would like to browse " $payload " and put the information in php variables like:
$applicationID = .... ; $rxInfo[] = .... ;
i already try somthing like "foreach" but i could not succes, can you help me please, thanks :).
Best regard,
DIDOUH JAWAD