psy Posted May 31, 2023 Share Posted May 31, 2023 I've set up a page to receive responses to events from another app's webhooks and it's working fine. The sending server needs to receive a http response of 200 before retrying. When the set number of retries fail, the web hook will be disabled by the sending host. From what I've read, often the 200 response will be returned auto-magically by the receiving host (in this case, PW). Doesn't appear to be happening. The sending host keeps retrying. I'd like to deliberately send the success response back to the sending host and I suspect https://processwire.com/api/ref/wire-http/send-status-header/ will be in the mix somewhere. Just not sure how to set it up. So far I have: <?php namespace ProcessWire: $phpInput = @file_get_contents("php://input"); $payload = json_decode($phpInput); if(!$payload->scope) exit(); // not valid BC webhook // need to send the 200 response here to let BC know the response was received successfully Guidance much appreciated. Cheers psy Link to comment Share on other sites More sharing options...
Tiberium Posted May 31, 2023 Share Posted May 31, 2023 This is how i do it: // Return a valid status code such as 200 OK. header('HTTP/1.1 200 OK'); // By most Webhooks,i also want to give a json return header('Content-Type: application/json'); 2 Link to comment Share on other sites More sharing options...
psy Posted May 31, 2023 Author Share Posted May 31, 2023 @Denis Schultz so that's all I need? Just a header? Link to comment Share on other sites More sharing options...
Jan Romero Posted May 31, 2023 Share Posted May 31, 2023 This is how I do it: http_response_code(200); But 200 is the default anyway. It should always be sent unless you change it or an exception happens. I think @Denis Schultz may be on to something with the Content-Type header? 3 Link to comment Share on other sites More sharing options...
Tiberium Posted May 31, 2023 Share Posted May 31, 2023 29 minutes ago, psy said: @Denis Schultz so that's all I need? Just a header? yep. You set the header of the return package. The next line is from my snippet... 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now