php - Server Sent Events triggered by receiving API POST -
i'm trying watch event notifications google calendar api's trigger endpoint php file:
use sse\event; use sse\sse; //create event handler class youreventhandler implements event { public function update(){ //here's place send data return 'hello, world!'; } public function check(){ //here's place check when data needs update if ($_server['request_method'] == 'post') { // trigger on api post request - not working foreach($_server $name => $value) { if (strpos($name, 'goog') !== false) { //return ("\$_server['$name'] => $value"); // skriv ut verdien med variabelnavnet og innholdet den. return true; } } } //return true; } } $sse = new sse(); //create libsse instance $sse->addeventlistener('event_name', new youreventhandler());//register event handler $sse->start();//start event loop ?>
i using libsse-php library https://github.com/licson0729/libsse-php
problem: post message google api correctly verified ok sending received headers error.log, i'm not able trigger endpoint php file in way client file stream getting triggered:
var sse = new eventsource('/notifications/notification-endpoint.php'); sse.addeventlistener('event_name',function(e){ var data = e.data; //handle data here console.log('her kommer data!!') console.log( data ) },false);
hope feedback on how fetch post headers external api's trigger php endpoint purpose of triggering sse.
Comments
Post a Comment