我的PHP chatbot使用php:// input接收多个JSON。它获取输入消息(这是正确的),但随后它接收到由机器人(响应)发送的消息,交付确认和读取确认的JSON。
我怎样才能保留第一个JSON?
我需要它,因为当我向我的机器人发送附件时会出现问题,它会处理错误的JSON而我无法从中获取URL。
我有这个代码来处理输入:
$input = json_decode(file_get_contents('php://input'), true);
file_put_contents('idkResponse.txt', file_get_contents('php://input') . PHP_EOL, FILE_APPEND);
我得到了所有这些JSON
{"object":"page","entry":[{"id":"XXXXX","time":1496729805870,"messaging":[{"sender":{"id":"XXXXX"},"recipient":{"id":"XXXXX"},"timestamp":1496729805429,"message":{"mid":"mid.$XXXXX","seq":1459814,"text":"Hey"}}]}]}
{"object":"page","entry":[{"id":"XXXXX","time":1496729806679,"messaging":[{"sender":{"id":"XXXXX"},"recipient":{"id":"XXXXX"},"timestamp":1496729806556,"message":{"is_echo":true,"app_id":XXXXX,"mid":"mid.$XXXXX","seq":1459815,"text":"Wut?"}}]}]}
{"object":"page","entry":[{"id":"XXXXX","time":1496729806873,"messaging":[{"sender":{"id":"XXXXX"},"recipient":{"id":"XXXXX"},"timestamp":1496729806873,"delivery":{"mids":["mid.$XXXXX"],"watermark":XXXXX,"seq":0}}]}]}
{"object":"page","entry":[{"id":"XXXXX","time":1496729808233,"messaging":[{"sender":{"id":"XXXXX"},"recipient":{"id":"XXXXX"},"timestamp":1496729808232,"read":{"watermark":XXXXX,"seq":0}}]}]}
谢谢