nexmo-bundle/Resources/doc/index.md

84 lines
1.9 KiB
Markdown
Raw Normal View History

2013-12-09 19:52:03 +00:00
JhgNexmoBundle
==================
Integrates <a href="https://www.nexmo.com/">Nexmo</a> services in Symfony2. You require an API key/secret pair (you can try it for free).
Installation
------------
Add this bundle to your `composer.json` file:
{
"repositories": [
{
"type": "vcs",
2014-06-07 09:57:08 +00:00
"url": "https://github.com/javihgil/nexmo-bundle.git"
2013-12-09 19:52:03 +00:00
}
],
"require": {
2014-06-07 09:57:08 +00:00
"javihgil/nexmo-bundle": "dev-master"
2013-12-09 19:52:03 +00:00
}
}
Register the bundle in 'app/AppKernel.php':
// app/AppKernel.php
public function registerBundles()
{
return array(
// ...
new Jhg\NexmoBundle\JhgNexmoBundle(),
);
}
Configuration
-------------
Configure your app config in `app/config/parameters.yml`.
# app/config/parameters.yml
nexmo_api_key: your_nexmo_api_key
nexmo_api_secret: your_nexmo_api_key
nexmo_from_name: App Name
If you want distribute your app in `app/config/parameters.yml.dist` too:
# app/config/parameters.yml.dist
nexmo_api_key: ~
nexmo_api_secret: ~
nexmo_from_name: ~
Enable the bundle's configuration in `app/config/config.yml`:
# app/config/config.yml
jhg_nexmo:
api_key: %nexmo_api_key%
api_secret: %nexmo_api_secret%
from_name: %nexmo_from_name%
Usage
-----
### Send SMS with service
2014-04-14 14:36:54 +00:00
$sender = $this->getContainer()->get('jhg_nexmo_sms');
$sender->sendText($number, $message, $fromName);
2013-12-09 19:52:03 +00:00
If no $fromName is provided 'jhg_nexmo.from_name' is used. This from name is limited to 11 characters (spaces and special chars are not allowed).
### Send SMS with command
You can send a SMS message using the proviced command
php app/console nexmo:sms:send +34666555444 MyApp "Hello World!!"
Reference
---------
https://docs.nexmo.com/index.php/messaging-sms-api/send-message