Jump to content

Recommended Posts

Posted

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

Posted

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');

 

  • Like 2
Posted

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?

  • Like 3

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...