|
| 1 | +Nexmo for Laravel 4 |
| 2 | +============== |
| 3 | + |
| 4 | +Implements a service for Nexmo messaging based on |
| 5 | + |
| 6 | +### Composer Configuration |
| 7 | + |
| 8 | +Include the artistan nexmo package as a dependency in your `composer.json` [Packagist](https://packagist.org/packages/artistan/nexmo): |
| 9 | + |
| 10 | + "artistan/nexmo": "0.1.*" |
| 11 | + |
| 12 | +### Installation |
| 13 | + |
| 14 | +Once you update your composer configuration, run `composer install` to download the dependencies. |
| 15 | + |
| 16 | +Add a ServiceProvider to your providers array in `app/config/app.php`: |
| 17 | + |
| 18 | + 'providers' => array( |
| 19 | + |
| 20 | + 'Artistan\Nexmo\NexmoServiceProvider', |
| 21 | + |
| 22 | + ) |
| 23 | + |
| 24 | +### Usage - work in progress |
| 25 | + |
| 26 | +Sending SMS via the Nexmo SMS gateway. |
| 27 | + |
| 28 | + |
| 29 | +Quick Examples |
| 30 | +-------------- |
| 31 | + |
| 32 | +1) Sending an SMS |
| 33 | + |
| 34 | + $sms = new Artistan\Nexmo\Service\Message\Sms; |
| 35 | + $result = $sms->sendText('15005554320','15555633637','dude, this is from a laravel package'); |
| 36 | + |
| 37 | +2) Recieving SMS |
| 38 | + |
| 39 | +// TODO:: setup routing for this... |
| 40 | + $sms = new Artistan\Nexmo\Service\Message\Sms; |
| 41 | + if ($sms->inboundText()) { |
| 42 | + $sms->reply('You said: ' . $sms->text); |
| 43 | + } |
| 44 | + |
| 45 | + |
| 46 | + |
| 47 | +3) Recieving a message receipt |
| 48 | + |
| 49 | +// TODO:: setup routing for this... |
| 50 | + $receipt = new Artistan\Nexmo\Service\Receipt; |
| 51 | + if ($receipt->exists()) { |
| 52 | + switch ($receipt->status) { |
| 53 | + case $receipt::STATUS_DELIVERED: |
| 54 | + // The message was delivered to the handset! |
| 55 | + break; |
| 56 | + |
| 57 | + case $receipt::STATUS_FAILED: |
| 58 | + case $receipt::STATUS_EXPIRED: |
| 59 | + // The message failed to be delivered |
| 60 | + break; |
| 61 | + } |
| 62 | + } |
| 63 | + |
| 64 | + |
| 65 | + |
| 66 | +4) List purchased numbers on your account |
| 67 | + |
| 68 | + $account = new Artistan\Nexmo\Service\Account; |
| 69 | + $numbers = $account->numbersList(); |
| 70 | + |
| 71 | + |
| 72 | + |
| 73 | + |
| 74 | + |
| 75 | + |
| 76 | +Most Frequent Issues |
| 77 | +-------------------- |
| 78 | + |
| 79 | + Sending a message returns false. |
| 80 | + |
| 81 | + This is usually due to your webserver unable to send a request to |
| 82 | + Nexmo. Make sure the following are met: |
| 83 | + |
| 84 | + 1) Either CURL is enabled for your PHP installation or the PHP |
| 85 | + option 'allow_url_fopen' is set to 1 (default). |
| 86 | + |
| 87 | + 2) You have no firewalls blocking access to rest.nexmo.com/sms/json |
| 88 | + on port 443. |
| 89 | + |
| 90 | + |
| 91 | + |
| 92 | + Your message appears to have been sent but you do not recieve it. |
| 93 | + |
| 94 | + Run the example.php file included. This will show any errors that |
| 95 | + are returned from Nexmo. |
0 commit comments