# Webhook to PHP

**URL:** <https://www.thethingsnetwork.org/forum/t/webhook-to-php/67284>\
**Category:** Uncategorized\
**Created:** [March 18, 2024, 10:09pm UTC](https://www.thethingsnetwork.org/forum/t/webhook-to-php/67284 "2024-03-18T22:09:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ruchesconnectees](https://www.thethingsnetwork.org/forum/letter_avatar_proxy/v4/letter/r/e47c2d/32.png) [@ruchesconnectees](https://www.thethingsnetwork.org/forum/u/ruchesconnectees)\
**Post date:** [March 18, 2024, 10:09pm UTC](https://www.thethingsnetwork.org/forum/t/webhook-to-php/67284/1 "2024-03-18T22:09:26Z")

</div>

Here is what my JSON receives from TTN cloud up to webhook.site.  
With all my code below, I receive success =\> true, message =\> ‘Data received successfully’, but I receive null in data.  
Why? Do you have any advice to give me ?

JSON :

{  
“uplink\_message”: {  
“decoded\_payload”: {  
“humidity”: 52.49,  
“pressure”: 1015.64,  
“temperature1”: 22.87,  
“temperature2”: 22.71  
}  
}  
}

Controllers :

class InsertData extends ResourceController  
{  
protected $modelName = ‘App\Models\MinsererDonnees’;  
protected $format = ‘json’;

```
// Function to retrieve the data
public function index()
{
    // Retrieves the JSON data sent by the request
    $queryData = file_get_contents('php://input');

    // Checks whether data has been received
    if ($queryData !== false) {
        // Responds to the request with a success message and the data received
        return $this->response->setJSON([
            'success' => true,
            'message' => 'Data received successfully',
            'data' => json_decode($queryData, true)
        ])->setStatusCode(200);
    } else {
        // Responds to the request with an error message if no data has been received
        return $this->response->setJSON([
            'success' => false,
            'message' => 'Error retrieving request data'
        ])->setStatusCode(400);
    }
}

```

}

---

<div class="post-metadata">

**Author:** ![descartes](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/descartes/32/47220_2.png) [@descartes](https://www.thethingsnetwork.org/forum/u/descartes)\
**Post date:** [March 18, 2024, 11:55pm UTC](https://www.thethingsnetwork.org/forum/t/webhook-to-php/67284/2 "2024-03-18T23:55:05Z")

</div>

Can you confirm that you are running this PHP on [https://webhook.site](https://webhook.site)?

---

<div class="post-metadata">

**Author:** ![ruchesconnectees](https://www.thethingsnetwork.org/forum/letter_avatar_proxy/v4/letter/r/e47c2d/32.png) [@ruchesconnectees](https://www.thethingsnetwork.org/forum/u/ruchesconnectees)\
**Post date:** [March 19, 2024, 8:24am UTC](https://www.thethingsnetwork.org/forum/t/webhook-to-php/67284/3 "2024-03-19T08:24:28Z")

</div>

Yes, I confirm that I am running this PHP on [https://webhook.site](https://webhook.site)

---

<div class="post-metadata">

**Author:** ![descartes](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/descartes/32/47220_2.png) [@descartes](https://www.thethingsnetwork.org/forum/u/descartes)\
**Post date:** [March 19, 2024, 10:35am UTC](https://www.thethingsnetwork.org/forum/t/webhook-to-php/67284/4 "2024-03-19T10:35:26Z")

</div>

I can’t see how that works - I know it has it’s own scripting support that is loosely based on PHP but not full-on PHP like you have.

And by implication, if you return something, it will go back to the source, which is TTN.

What do the webhook.site people say?
