Created
June 8, 2021 17:48
-
-
Save jeremeamia/fe7f3bcc951d4b455635eff4c7c54dc5 to your computer and use it in GitHub Desktop.
Revisions
-
jeremeamia created this gist
Jun 8, 2021 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,24 @@ <?php function parse_slack_request(string $body): array { if (empty($body)) { return []; } if ($body[0] === '{') { $data = json_decode($body, true); } else { parse_str($body, $data); } if (isset($data['payload'])) { $data = json_decode(urldecode($data['payload']), true); } return $data; } // Example $body = file_get_contents('php://input'); $data = parse_slack_request($body);