Skip to content

Commit

Permalink
Update the send SMS block to match new spec (Vonage#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
lornajane authored and Mark Lewin committed Mar 19, 2019
1 parent 5b80b52 commit 31cf972
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions sms/send-sms.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,20 @@
$basic = new \Nexmo\Client\Credentials\Basic(NEXMO_API_KEY, NEXMO_API_SECRET);
$client = new \Nexmo\Client($basic);

$message = $client->message()->send([
'to' => TO_NUMBER,
'from' => 'Acme Inc',
'text' => 'A text message sent using the Nexmo SMS API'
]);
try {
$message = $client->message()->send([
'to' => TO_NUMBER,
'from' => 'Acme Inc',
'text' => 'A text message sent using the Nexmo SMS API'
]);
$response = $message->getResponseData();

if($response['messages'][0]['status'] == 0) {
echo "The message was sent successfully\n";
} else {
echo "The message failed with status: " . $response['messages'][0]['status'] . "\n";
}
} catch (Exception $e) {
echo "The message was not sent. Error: " . $e->getMessage() . "\n";
}

var_dump($message->getResponseData());

0 comments on commit 31cf972

Please sign in to comment.