Last active
July 12, 2023 02:25
-
-
Save AaEzha/b40183b9b7299c996051ebee31358fa5 to your computer and use it in GitHub Desktop.
Example of webhook client
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 characters
| <?php | |
| // Retrieve the webhook payload | |
| $payload = file_get_contents('php://input'); | |
| // Process the webhook payload | |
| // ... Perform any necessary actions or data processing based on the received payload | |
| // Prepare the response data | |
| $responseData = [ | |
| 'status' => 'success', | |
| 'message' => 'Webhook received successfully', | |
| ]; | |
| // Convert the response data to JSON | |
| $responseJson = json_encode($responseData); | |
| // Set the response headers | |
| header('Content-Type: application/json'); | |
| header('Content-Length: ' . strlen($responseJson)); | |
| // Send the response | |
| echo $responseJson; |
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 characters
| <?php | |
| $data = file_get_contents("php://input"); | |
| $events = json_decode($data, true); | |
| $mysqli = new mysqli("localhost","db_username","db_password","db_name"); | |
| // Check connection | |
| if ($mysqli -> connect_errno) { | |
| echo "Failed to connect to MySQL: " . $mysqli -> connect_error; | |
| exit(); | |
| } | |
| $test = $mysqli -> query("insert into trx (keterangan) values ('$data')"); | |
| if ($test) { | |
| $mysqli -> query("insert into trx (keterangan) values ('Tes berhasil')"); | |
| } else { | |
| $mysqli -> query("insert into trx (keterangan) values ('Tes gagal')"); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment