0

I am using slack, built a BOT that and subscribed an event message.group I want to build my projects via my BOT, once I post my predefined deploy command it will start execution the script I built, but it will try again and again by self after post a single command.

slack documentation says:

Your app should respond to the event request with an HTTP 2xx within three seconds. If it does not, we'll consider the event delivery attempt failed. After a failure, we'll retry three times, backing off exponentially. We recommend responding to events with a HTTP 200 OK as soon as you can. You may want to avoid processing and reacting to events within the same process handling event reception.

I have set below code at the beginning of my script like this way-

header("HTTP/1.1 200 OK");
echo "HTTP 200 OK";

it dose not work

mizan3008
  • 369
  • 3
  • 17

2 Answers2

0

Add Header, and return something

header('HTTP/1.1 200 Success', true, 200);
return 'Success';
Vahe Galstyan
  • 1,681
  • 1
  • 12
  • 25
0

Responding with HTTP OK to the calling server in the midst of a running PHP script is not trivial. The web server will in most cases prevent any OK sending before the script is terminated. There are two general approaches that will work:

  1. Manage output puffer and force webserver to send OK back (depends on webserver configuration)

  2. Start 2nd script asynchronously to process request further and terminate 1st script within 3 secs. (which will automatically send an HTTP OK back)

See this question for an explanation on how to implement those approaches for Slack in PHP.

See this answer for a solution that worked for me.

Erik Kalkoken
  • 30,467
  • 8
  • 79
  • 114