# PHP Example for Webhook Events

**URL:** <https://devforum.zoom.us/t/php-example-for-webhook-events/7810>\
**Category:** API and Webhooks\
**Created:** [January 31, 2020, 4:34am UTC](https://devforum.zoom.us/t/php-example-for-webhook-events/7810 "2020-01-31T04:34:46Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jkhliffz](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/jkhliffz/32/3097_2.png) [@jkhliffz](https://devforum.zoom.us/u/jkhliffz)\
**Post date:** [January 31, 2020, 4:34am UTC](https://devforum.zoom.us/t/php-example-for-webhook-events/7810/1 "2020-01-31T04:34:46Z")

</div>

**Description**  
Can I have a simple php example to make a webhook event works for webinar.participant\_joined?

**Which App Type (OAuth / Chatbot / JWT / Webhook)?**  
Webhook

**Which Endpoint/s?**  
I am setting up on this link: [https://app.vaservicesph.com/api/zoom](https://app.vaservicesph.com/api/zoom)

Thank you.

---

<div class="post-metadata">

**Author:** ![jkhliffz](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/jkhliffz/32/3097_2.png) [@jkhliffz](https://devforum.zoom.us/u/jkhliffz)\
**Post date:** [January 31, 2020, 6:44am UTC](https://devforum.zoom.us/t/php-example-for-webhook-events/7810/2 "2020-01-31T06:44:11Z")

</div>

I used this code to get the data:  
**$json = file\_get\_contents(“php://input”)**

The data is then added to my file using this code:  
**file\_put\_contents($myFile, $data)**

but when I try to get a specific data like **id** , **user\_id** , and **user\_name** , I got no result.

I tried using **$json-\>payload-\>object-\>id;**

Any help would be appreciated.  
Thank you.

---

<div class="post-metadata">

**Author:** ![jkhliffz](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/jkhliffz/32/3097_2.png) [@jkhliffz](https://devforum.zoom.us/u/jkhliffz)\
**Post date:** [January 31, 2020, 9:08am UTC](https://devforum.zoom.us/t/php-example-for-webhook-events/7810/3 "2020-01-31T09:08:32Z")

</div>

I got it!  
Here is my code:

```php
        <?php 
        if ($_SERVER['REQUEST_METHOD'] == 'POST'){

        	$data = file_get_contents("php://input");
        	$decode = json_decode($data);

        	// expecting valid json
            if (json_last_error() !== JSON_ERROR_NONE) {
                die(header('HTTP/1.0 415 Unsupported Media Type'));
            }

        	$file = 'events.json';

        	/**
             * Do something with object, structure will be like:
             * $object->accountId
             * $object->details->items[0]['contactName']
             */
            // dump to file so you can see

            file_put_contents($file, print_r($decode->event, true) . PHP_EOL, FILE_APPEND);
        }

        ?>

```

😀

---

<div class="post-metadata">

**Author:** ![tommy](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/tommy/32/72769_2.png) [@tommy](https://devforum.zoom.us/u/tommy)\
**Post date:** [January 31, 2020, 8:40pm UTC](https://devforum.zoom.us/t/php-example-for-webhook-events/7810/4 "2020-01-31T20:40:20Z")

</div>

Hey @jkhliffz, thanks for posting and using Zoom!

I am glad you figured out the issue!

Let us know if you ever have additional questions! 🙂

Thanks,  
Tommy

---

<div class="post-metadata">

**Author:** ![DeveloperBot](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/developerbot/32/12632_2.png) [@DeveloperBot](https://devforum.zoom.us/u/DeveloperBot)\
**Post date:** [August 21, 2020, 7:14pm UTC](https://devforum.zoom.us/t/php-example-for-webhook-events/7810/5 "2020-08-21T19:14:09Z")

</div>

Closed on August 21, 2020, 7:14pm UTC


