i'm trying to the following:
I have 1 page that is called request.php that receives a post from a webhook of hipmob
Documentation: https://www.hipmob.com/documentation/chat-events.html
<?php
$entityBody = file_get_contents('php://input');
$post_data = $_POST;
$data = json_encode($post_data, JSON_PRETTY_PRINT);
$file = 'webhook.txt';
$current = file_get_contents($file);
file_put_contents($file, $data);
//error_log($data);
?>
Example output:
{
"app": "eba978375b294260bd884a72afd5eb75",
"appname": "Worten Suporte",
"event": "chat.message",
"started": "2015-06-12T08:32:56+00:00",
"ip": "62.28.231.158",
"platform": "Windows\/Chrome",
"version": "43",
"timestamp": "2015-06-12T09:32:36+00:00",
"body": "mensagem",
"properties": "{\"as\":\"text\"}",
"id": "70acc6b20cbc44f18f99e2e922130904",
"email": "eba978375b294260bd884a72afd5eb75.70acc6b20cbc44f18f99e2e922130904@app.hipmob.com",
"visits": "1",
"locale": "pt",
"userdata:context": "viewing file:\/\/\/C:\/Users\/hp\/Desktop\/chattest.html title: ;url: file:\/\/\/C:\/Users\/hp\/Desktop\/chattest.html",
"state": "",
"signature": "622869e9210ba4599e95322cafd7f8123552375b44314e502ceb53972f9bfadb1a49d965f3102d8f30028690bc606632c6878e4ff95003ec15c0ea2749a8bd84"
}
I want to know if its possible everytime i receive a post in this page i get a notification in other page let's say:
example.php
and refresh it with the new data
You should store the data you received from hipmob in a database with lets say a flag 'seen'.
Then you could create an AJAX call from the example.php page to get notifications that haven't been seen yet in the database and the refresh the data based on that.
To do that you need to maintain last inserted row with a visibility flag.
After that you will have to call ajax (on example.php) after a particular interval by using settimeout. In that ajax call you can compare the visibility flag and refresh the page.