Wallogit.com
2017 © Pedro Peláez
[user@project_path]$ composer require crboy/nexmo-php-lib
Sending an SMS, (*1)
$sms = new NexmoMessage('account_key', 'account_secret');
$sms->sendText('+886900000000', 'MyApp', 'Hello world!');
Recieving SMS, (*2)
$sms = new NexmoMessage('account_key', 'account_secret');
if ($sms->inboundText()) {
$sms->reply('You said: ' . $sms->text);
}
Recieving a message receipt, (*3)
$receipt = new NexmoReceipt();
if ($receipt->exists()) {
switch ($receipt->status) {
case $receipt::STATUS_DELIVERED:
// The message was delivered to the handset!
break;
case $receipt::STATUS_FAILED:
case $receipt::STATUS_EXPIRED:
// The message failed to be delivered
break;
}
}
List purchased numbers on your account, (*4)
$account = new NexmoAccount('account_key', 'account_secret');
$numbers = $account->numbersList();
This is usually due to your webserver unable to send a request to Nexmo. Make sure the following are met:, (*5)
Run the example.php file included. This will show any errors that are returned from Nexmo., (*6)