Skip to content

Commit 29ed577

Browse files
authored
Merge pull request #92 from Vonage/feature/signed-webhook-example
Feature/signed webhook example
2 parents 3bd2220 + 3bb49e9 commit 29ed577

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

.env-example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
VONAGE_API_KEY=
22
VONAGE_API_SECRET=
3+
VONAGE_SIGNATURE_SECRET=
34
VONAGE_APPLICATION_ID=12a3b4cd-a1b2-1ab2-a1b2-a1234bc5d678
45
VONAGE_APPLICATION_PRIVATE_KEY_PATH=
56
FROM=

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
"require": {
33
"vonage/client": "^2.3",
44
"vlucas/phpdotenv": "^2.5",
5-
"lcobucci/jwt": "^3.0"
5+
"lcobucci/jwt": "^4.0"
66
}
77
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
require_once __DIR__ . '../../config.php';
3+
require_once __DIR__ . '../../vendor/autoload.php';
4+
5+
$signature = new Vonage\Client\Credentials\SignatureSecret(VONAGE_API_KEY, VONAGE_SIGNATURE_SECRET, 'sha256');
6+
$client = new Vonage\Client($signature);
7+
8+
$message = new Vonage\SMS\Message\SMS(
9+
TO_NUMBER,
10+
FROM_NUMBER,
11+
'This is a signed text'
12+
);
13+
14+
$client->sms()->send($message);
15+
16+
// Incoming Request
17+
$signature = new Vonage\Client\Signature(VONAGE_API_KEY, VONAGE_SIGNATURE_SECRET, 'sha256');
18+
$isValid = $signature->check($_GET['sig']);

0 commit comments

Comments
 (0)