Skip to content

Instantly share code, notes, and snippets.

@stephangroen
Created October 17, 2013 16:46
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stephangroen/f9a51c8bbe0f910f4e80 to your computer and use it in GitHub Desktop.
Save stephangroen/f9a51c8bbe0f910f4e80 to your computer and use it in GitHub Desktop.
Receiving a JSON hook
<?php
// Fetch the entire body to a variable (this will contain the raw data)
$webhook = file_get_contents('php://input');
// Decode the JSON to an array
$webhook_array = json_decode($webhook, true);
// Do some stuff with the data you received, for example write contents to a file
file_put_contents('webhook.txt', print_r($webhook_array, true));
// Send a success header, so Picqer knows you have succesfully received the data
header('HTTP/1.1 200 OK');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment