dongqiuxu2270 2015-06-12 09:54
浏览 89
已采纳

php - 将数据从一个php页面发送到另一个php页面并使用新数据刷新它

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

  • 写回答

2条回答 默认 最新

  • duanpin9531 2015-06-12 09:58
    关注

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 要这个数学建模编程的代码 并且能完整允许出来结果 完整的过程和数据的结果
  • ¥15 html5+css和javascript有人可以帮吗?图片要怎么插入代码里面啊
  • ¥30 Unity接入微信SDK 无法开启摄像头
  • ¥20 有偿 写代码 要用特定的软件anaconda 里的jvpyter 用python3写
  • ¥20 cad图纸,chx-3六轴码垛机器人
  • ¥15 移动摄像头专网需要解vlan
  • ¥20 access多表提取相同字段数据并合并
  • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
  • ¥20 Java-Oj-桌布的计算
  • ¥15 powerbuilder中的datawindow数据整合到新的DataWindow