# Parsing HTTP integration data in PHP

**URL:** <https://www.thethingsnetwork.org/forum/t/parsing-http-integration-data-in-php/16928>\
**Category:** Application Development\
**Created:** [August 16, 2018, 7:20pm UTC](https://www.thethingsnetwork.org/forum/t/parsing-http-integration-data-in-php/16928 "2018-08-16T19:20:57Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![UdLoRa](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/udlora/32/45330_2.png) [@UdLoRa](https://www.thethingsnetwork.org/forum/u/UdLoRa)\
**Post date:** [August 17, 2018, 1:29pm UTC](https://www.thethingsnetwork.org/forum/t/parsing-http-integration-data-in-php/16928/2 "2018-08-17T13:29:31Z")

</div>

You are doing a json\_decode and then saving, and as text, which is not appropriate because $ttndtajs is no more text but an object. You can use var\_export() to obtain a parsable serialization of that object, however is is like saving JSON directly.

When I started using TTN, I used this small PHP script to log raw (i.e., JSON) data from nodes:

```
<?php 
    //Receive from TTN
    $postdata = file_get_contents('php://input');
    file_put_contents('yourfile.txt', $postdata . PHP_EOL, FILE_APPEND);
    echo 'ok';
?>

```

Then I have another script that reads and decodes each line of such file, showing data on an HTML table. This includes something like:

```
$log=file('yourfile.txt');
foreach($log as $r) {
	$data=json_decode($r); 
	$dev_id =$data->dev_id;
	$HW=$data->hardware_serial;
    $freq=$data->metadata->frequency;
    $datarate=$data->metadata->data_rate;
    ...
}
```

---

_[View the full topic](https://www.thethingsnetwork.org/forum/t/parsing-http-integration-data-in-php/16928)._
