项目作者: edragonconnect

项目描述 :
Aliyun openapi tools written in elixir
高级语言: Elixir
项目地址: git://github.com/edragonconnect/ex_aliyun_openapi.git
创建时间: 2019-03-27T02:55:50Z
项目社区:https://github.com/edragonconnect/ex_aliyun_openapi

开源协议:

下载


ExAliyun.OpenAPI

Module Version
Hex Docs
Total Download
Last Updated

Description

ExAliyun.OpenAPI supports aliyun openapis:

  • CPS(移动推送服务)
  • STS(短期访问权限管理)
  • SMS(短信服务)
  • AFS(人机验证)
  • CodeUp(云效任务管理)
  • GeoIP(查询 IP 地理位置)
  • more to be supported

Installation

If available in Hex, the package can be installed
by adding ex_aliyun_openapi to your list of dependencies in mix.exs:

  1. def deps do
  2. [
  3. {:ex_aliyun_openapi, "~> 0.8"}
  4. ]
  5. end

Configuration

You should add configs for your services in this way.

  1. config :ex_aliyun_openapi, type,
  2. access_key_id: "YOUR CPS ACCESS KEY ID",
  3. access_key_secret: "YOUR CPS ACCESS KEY SECRET"

type support [:cps, :sts, :sms, :global_sms, :afs, :codeup, :geoip]

Call the apis

You can find the api params in https://help.aliyun.com.
Then you can choose the service, and just put the params to it.

  1. params = %{
  2. "Action" => "AssumeRole",
  3. "RoleArn" => "**YOUR RoleArn**",
  4. "RoleSessionName" => "default",
  5. "DurationSeconds" => 3600,
  6. }
  7. ExAliyun.OpenAPI.call_sts(params)
  8. # or
  9. ExAliyun.OpenAPI.call_sts(params, access_key_id: "ID", access_key_secret: "SECRET")
  1. params = %{
  2. "Action" => "PushNoticeToAndroid",
  3. "AppKey" => "**YOUR AppKey**",
  4. "Target" => "DEVICE",
  5. "TargetValue" => "**YOUR device_id**",
  6. "Title" => "TEST title",
  7. "Body" => "Hello, this is the notice body"
  8. }
  9. ExAliyun.OpenAPI.call_cps(params)
  10. # or
  11. ExAliyun.OpenAPI.call_cps(params, access_key_id: "ID", access_key_secret: "SECRET")

To add more services to this repo

  1. You should add the specific function into ex_aliyun_openapi.ex.
  2. Complete the corresponding unit tests.