Browse code

Added README.md appinfo/info.xml appinfo/signature.json lib/Controller/AuthorApiController.php and the providers directory

DoubleBastionAdmin authored on 20/08/2022 16:33:00
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,37 @@
1
+<?php
2
+require_once(__DIR__ . '/../init.php');
3
+
4
+// Please fetch the public key from: https://portal.telnyx.com/#/app/account/public-key
5
+\Telnyx\Telnyx::setPublicKey('######');
6
+
7
+$webhook_event = null;
8
+
9
+try {
10
+    
11
+    // Validate the webhook against the public key and retrieve the $webhook_event object
12
+    $webhook_event = \Telnyx\Webhook::constructFromRequest();
13
+
14
+
15
+} catch(\UnexpectedValueException $e) { // Invalid payload
16
+
17
+    // Output error message
18
+    echo $e;
19
+
20
+    // Send status code to signal that the webhook was NOT successfully received
21
+    http_response_code(400);
22
+    exit();
23
+} catch(\Telnyx\Exception\SignatureVerificationException $e) { // Invalid signature
24
+
25
+    // Output error message
26
+    echo $e;
27
+    
28
+    // Send status code to signal that the webhook was NOT successfully received
29
+    http_response_code(400);
30
+    exit();
31
+}
32
+
33
+// Now you can work with the $webhook_event object
34
+print_r($webhook_event);
35
+
36
+// Send status code to signal that the webhook was successfully received
37
+http_response_code(200);
0 38
\ No newline at end of file