https://github.com/erlangbureau/enexmo
Nexmo REST API client for Erlang
https://github.com/erlangbureau/enexmo
erlang nexmo
Last synced: 26 days ago
JSON representation
Nexmo REST API client for Erlang
- Host: GitHub
- URL: https://github.com/erlangbureau/enexmo
- Owner: erlangbureau
- License: mit
- Created: 2016-10-04T21:57:50.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2016-10-04T23:06:31.000Z (over 9 years ago)
- Last Synced: 2025-03-10T04:46:22.979Z (over 1 year ago)
- Topics: erlang, nexmo
- Language: Erlang
- Size: 50.8 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Nexmo Client Library for Erlang
===============================
Usage
-----
Begin by starting the nexmo app:
```erl
1> application:ensure_all_started(enexmo).
{ok,[crypto,asn1,public_key,ssl,inets,jsx,enexmo]}
```
Then register a chanel with your key and secret:
```erl
2> enexmo:create_channel(test, [{api_key, "api_key"}, {api_secret, "api_secret"}]).
ok
```
For newer endpoints that support JWT authentication such as the Voice API,
you can also specify the `application_id` and `private_key` arguments:
```erl
2> enexmo:create_channel(test, [{api_key, "api_key"}, {api_secret, "api_secret"}, {application_id, "application_id"}, {private_key, "private_key"}]).
ok
```
## SMS API
### Send a text message
```erl
3> enexmo:send_message(test, "Nexmo", "380920000911", "test msg").
{error,{server_error,<<"29">>,
<<"Non White-listed Destination - rejected">>}}
```
Docs: [https://docs.nexmo.com/messaging/sms-api/api-reference#request](https://docs.nexmo.com/messaging/sms-api/api-reference#request?utm_source=DEV_REL&utm_medium=github&utm_campaign=erlang-client-library)
## Verify API
### Start a verification
```erl
4> enexmo:start_verification(test, "380920000911", "Nexmo").
{ok,[{<<"request_id">>,
<<"37735891af52435292616476fdc7e4ae">>},
{<<"status">>,<<"0">>}]}
```
Docs: [https://docs.nexmo.com/verify/api-reference/api-reference#vrequest](https://docs.nexmo.com/verify/api-reference/api-reference#vrequest?utm_source=DEV_REL&utm_medium=github&utm_campaign=erlang-client-library)
The response contains a verification request id which you will need to
store temporarily (in the session, database, url etc).
### Check a verification
```erl
5> enexmo:check_verification(test, "37735891af52435292616476fdc7e4ae", "3100").
{ok,[{<<"request_id">>,
<<"37735891af52435292616476fdc7e4ae">>},
{<<"status">>,<<"0">>},
{<<"event_id">>,<<"070000000F65C3CB">>},
{<<"price">>,<<"0.10000000">>},
{<<"currency">>,<<"EUR">>}]}
```
Docs: [https://docs.nexmo.com/verify/api-reference/api-reference#check](https://docs.nexmo.com/verify/api-reference/api-reference#check?utm_source=DEV_REL&utm_medium=github&utm_campaign=erlang-client-library)
The verification request id comes from the call to the start_verification method.
The PIN code is entered into your application by the user.