Here's a PHP example showing you how to handle a Feed Control webhook:
<?php
// receive input
$json_string = file_get_contents("php://input");
$data = json_decode($json_string, true);
// get title and feed name
$item_title = $data['title'];
$feed_name = $data['feed']['name'];
// save to file (log.txt must be in same directory and writable)
file_put_contents('webhook_log.txt', "New item from $feed_name: $item_title");
// return success code
// (change to 500 - Internal Server Error - to test error response)
http_response_code(200);
// receive input
$json_string = file_get_contents("php://input");
$data = json_decode($json_string, true);
// get title and feed name
$item_title = $data['title'];
$feed_name = $data['feed']['name'];
// save to file (log.txt must be in same directory and writable)
file_put_contents('webhook_log.txt', "New item from $feed_name: $item_title");
// return success code
// (change to 500 - Internal Server Error - to test error response)
http_response_code(200);
You can name this something like webhook_test.php
and place it on a publicly accessible server. There must also be a writable file named webhook_log.txt
in the same directory for the script to write to.
Once these are in place, update the Webhooks URL field of your account, and enter the URL to your webhook_test.php file, e.g. https://www.example.com/webhook_test.php
Now every time a webhook is received, the webhook_log.txt file will contain a line that reads:
New item from [feed name]: [item title]
Note: the script will overwrite the file each time, so it will always only have one line.
Comments
0 comments
Please sign in to leave a comment.