Receive Incoming Webhook Data
Today I gonna share how can we receive data from webhook in PHP. It’s just a cinch but sometime feels really tricky.
Webhook:
Webhook is very useful way of getting update from external system. It notify when something happened on webhook server side. Webhook client is for receiving this update.
Receive Webhook Data:
Data from external source thrown on JSON format to receive in PHP follow below code snippets and use this file url as delivery url in webhook settings.
$json = file_get_contents(‘php://input’); //receiving json data
$data = json_decode($json, true); //decoding json
$file = fopen(‘text.txt’, “w+”);//creating file
fwrite($file, “Response: “.json_encode($data));//writing data on it full body
fclose($file);
Open text.txt file and see magic 🙂
I am professional Web Designer & Developer. I have 5+ years of experience in relevant field. Currently I am working for a private software company named “Ollyo” as a Senior Staff Software Engineer.