Giter Site home page Giter Site logo

luosimao's Introduction

luosimao

国内的luosimao短信接口类库,实现了短信的发送和语音验证码的发送。

通过go get获取类库

go get github.com/gogap/luosimao

示例代码

请将您自己的API密码和手机号填到下面对应的变量。

package main

import (
    "encoding/json"
    "fmt"

    "github.com/gogap/luosimao"
)

var voiceAuth luosimao.Authorization
var smsAuth luosimao.Authorization

func main() {
    voiceAuth = luosimao.Authorization{UserName: "api", Password: ""}
    smsAuth = luosimao.Authorization{UserName: "api", Password: ""}

    send_voice("13400000000", 123)
    send_sms("13400000000", "您的验证码是:1234 【公司签名】")
    voice_status()
    sms_status()
}

func send_voice(mobile string, code int32) {
    sender := luosimao.NewVoiceSender(voiceAuth, luosimao.JSON)
    resp, err := sender.Send(luosimao.VoiceRequest{Mobile: mobile, Code: code}, 1000)
    if err != nil {
        fmt.Println(err.Error())
    } else {
        b, _ := json.Marshal(resp)
        fmt.Println(string(b))
        fmt.Println(resp.ErrorDescription())
    }
}

func voice_status() {
    sender := luosimao.NewVoiceSender(voiceAuth, luosimao.JSON)
    resp, err := sender.Status(1000)
    if err != nil {
        fmt.Println(err.Error())
    } else {
        b, _ := json.Marshal(resp)
        fmt.Println(string(b))
        fmt.Println(resp.ErrorDescription())
    }
}

func send_sms(mobile, message string) {
    sender := luosimao.NewSMSSender(smsAuth, luosimao.JSON)
    resp, err := sender.Send(luosimao.SMSRequest{Mobile: mobile, Message: message}, 1000)
    if err != nil {
        fmt.Println(err.Error())
    } else {
        b, _ := json.Marshal(resp)
        fmt.Println(string(b))
        fmt.Println(resp.ErrorDescription())
    }
}

func sms_status() {
    sender := luosimao.NewSMSSender(smsAuth, luosimao.JSON)
    resp, err := sender.Status(1000)
    if err != nil {
        fmt.Println(err.Error())
    } else {
        b, _ := json.Marshal(resp)
        fmt.Println(string(b))
        fmt.Println(resp.ErrorDescription())
    }
}

luosimao's People

Contributors

xujinzheng avatar xigang avatar techlinf avatar

Stargazers

zhou avatar  avatar Larry Xu avatar Lee avatar

Watchers

James Cloos avatar  avatar L avatar  avatar Henry Huang 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.