Git Product home page Git Product logo

alidayu's Introduction

alidayu

Build Status Go Report Card GoDoc

package alidayu is a Golang SDK for alidayu(阿里大鱼) APIs.

Documentation

Example

    // Create a new client(创建一个新的Client实例).
    c := &alidayu.Client{AppKey: "", AppSecret: "", UseHTTPS: false}

    // ---------------------------------------
    // Send Verification Code in SMS(发送短信验证码).
    // ---------------------------------------
    // Set parameters(设置API所需的所有参数,包括公共参数和方法相关参数).
    params := map[string]string{}

    // Common parameters will be filled with default values automatically.
    // You may also set them to override default ones.
    // 公共参数会自动使用默认值填充,不需要用户设置.
    // 当然,用户可以使用自己的设置来覆盖默认值.
    //   params["format"] = "json"      // "json" or "xml"
    //   params["v"] = "2.0"            // "2.0" by default
    //   params["sign_method"] = "md5"  // "md5" or "hmac"

    // No need to set "timestamp" and "sign", these parameters will be calculated and filled automatically.
    // 不需要用户设置"timestamp"和"sign",这些参数会被自动计算和设置.

    // Set method specified parameters(设置方法相关特定参数).
    params["method"] = "alibaba.aliqin.fc.sms.num.send"           // Set method to send SMS(API接口名称).
    params["sms_type"] = "normal"                                 // Set SMS type(短信类型).
    params["sms_free_sign_name"] = ""                             // Set SMS signature(短信签名).
    params["sms_param"] = `{"code":"123456", "product":"My App"}` // Set variable for SMS template(短信模板变量).
    params["sms_template_code"] = ""                              // Set SMS template code(短信模板ID).
    params["rec_num"] = ""                                        // Set phone number to send SMS(短信接收号码).

    // Call Exec() to post the request.
    success, result, err := c.Exec(params)
    if err != nil {
            fmt.Fprintf(os.Stderr, "c.Exec() error: %v\nsuccess: %v\nresult: %v\n", err, success, result)
            return
    }

    fmt.Fprintf(os.Stderr, "c.Exec() successfully\nsuccess: %v\nresult: %s\n", success, result)

    // ------------------------------------------
    // Send Verification Code in Single Call(发送文本转语音通知验证码).
    // ------------------------------------------
    // Set Parameters.
    params = map[string]string{}
    params["method"] = "alibaba.aliqin.fc.tts.num.singlecall"     // Set method to make single call(API接口名称).
    params["tts_param"] = `{"code":"123456", "product":"My App"}` // Set variable for TTS template(文本转语音(TTS)模板变量).
    params["called_num"] = ""                                     // Set phone number to make single call(被叫号码).
    params["called_show_num"] = ""                                // Set show number(被叫号显).
    params["tts_code"] = ""                                       // Set TTS code(TTS模板ID).

    // Call Exec() to post the request.
    success, result, err = c.Exec(params)
    if err != nil {
            fmt.Fprintf(os.Stderr, "c.Exec() error: %v\nsuccess: %v\nresult: %v\n", err, success, result)
            return
    }

    fmt.Fprintf(os.Stderr, "c.Exec() successfully\nsuccess: %v\nresult: %s\n", success, result)

License

alidayu's People

Contributors

northbright avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.