You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+18-1Lines changed: 18 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -167,6 +167,8 @@ echo "The body of the message was: " . $message->getBody();
167
167
168
168
### Signing a Message
169
169
170
+
_You may also like to read the [documentation about message signing](https://developer.nexmo.com/concepts/guides/signing-messages)._
171
+
170
172
The SMS API supports the ability to sign messages by generating and adding a signature using a "Signature Secret" rather than your API secret. The algorithms supported are:
171
173
172
174
*`md5hash1`
@@ -180,11 +182,26 @@ Both your application and Nexmo need to agree on which algorithm is used. In the
180
182
Create a client using these credentials and the algorithm to use, for example:
181
183
182
184
```php
183
-
$client = new Nexmo\Client(new Nexmo\Client\Credentials\SignatureSecret(API_KEY, API_SECRET, 'sha256'));
185
+
$client = new Nexmo\Client(new Nexmo\Client\Credentials\SignatureSecret(API_KEY, SIGNATURE_SECRET, 'sha256'));
184
186
```
185
187
186
188
Using this client, your SMS API messages will be sent as signed messages.
187
189
190
+
### Verifying an Incoming Message Signature
191
+
192
+
_You may also like to read the [documentation about message signing](https://developer.nexmo.com/concepts/guides/signing-messages)._
193
+
194
+
If you have message signing enabled for incoming messages, the SMS webhook will include the fields `sig`, `nonce` and `timestamp`. To verify the signature is from Nexmo, you create a Signature object using the incoming data, your signature secret and the signature method. Then use the `check()` method with the actual signature that was received (usually `_GET['sig']`) to make sure that it is correct.
195
+
196
+
```php
197
+
$signature = new \Nexmo\Client\Signature($_GET, SIGNATURE_SECRET, 'sha256');
198
+
199
+
// is it valid? Will be true or false
200
+
$isValid = $signature->check($_GET['sig']);
201
+
```
202
+
203
+
Using your signature secret and the other supplied parameters, the signature can be calculated and checked against the incoming signature value.
204
+
188
205
### Starting a Verification
189
206
190
207
Nexmo's [Verify API][doc_verify] makes it easy to prove that a user has provided their own phone number during signup,
0 commit comments