项目作者: scripbox

项目描述 :
An Elixir client for sending SMS with txtLocal APIs
高级语言: Elixir
项目地址: git://github.com/scripbox/txt_local_ex.git
创建时间: 2017-12-04T08:05:15Z
项目社区:https://github.com/scripbox/txt_local_ex

开源协议:MIT License

下载


TxtLocalEx

An Elixir client for sending SMS with txtLocal APIs

Install

  1. Add txt_local_ex to your list of dependencies in mix.exs:
  1. def deps do
  2. [{:txt_local_ex, "~> 0.1.0"}]
  3. end
  1. Ensure txt_local_ex is started before your application:
  1. def application do
  2. [applications: [:txt_local_ex]]
  3. end

Configure

Add the following to your config.exs file:

  1. config :txt_local_ex,
  2. rate_limit_scale: "RATE_LIMIT_SCALE", # in milli seconds
  3. rate_limit_count: "RATE_LIMIT_COUNT" # number of api calls allowed within the time scale
  4. http_client: TxtLocalEx.HTTPClient.HTTPoison
  • For Development/Test environments

Add the following to your config/dev.exs/config/test.exs file:

  1. config :your_app, :txt_local_ex_api, TxtLocalEx.InMemoryMessenger
  • For Staging/Production environments

Add the following to your config/staging.exs/config/production.exs file:

  1. config :your_app, :txt_local_ex_api, TxtLocalEx.HttpMessenger

Usage

  1. Set the messenger to use at the top level

    1. @txt_local_api_client Application.get_env(:your_app, :txt_local_ex_api)
  2. Send SMS

    • The send_sms/6 function sends an sms to a given phone number from a given phone number.
    1. # @txt_local_api_client.send_sms("YOUR_API_KEY", "from_number", "to_number", "body_text")
    2. iex(1)> @txt_local_api_client.send_sms("15005550001", "15005550002", "message text")