Code Monkey home page Code Monkey logo

upyun-sms-sdk's Introduction

upyun-sms-sdk

又拍云短信服务平台接口.NET C# SDK

使用

将这个生成DLL文件引用进你的项目。对了,无论如何,你还得引用Newtonsoft.Json这个玩意儿弄进的项目。

using UpyunSMSSDK;
using UpyunSMSSDK.Model;

Upyun上获取你的Token,它很关键。然后,实例化一个UpyunSMSClient对象。

var token = "***********************";
var client = new UpyunSMSClient(token);

发送短信

实例化一个message对象,参数为:接收手机号码、模板Id(你得有审核通过的模板)、短信参数(多个参数以“|”分割)。

var message = new Message("18888888888", "78", "1|注册");
var messageResult = client.SendMessages(message);

现在messageResult里面包含了接口返回的信息,通过这些信息再进行你下一步操作。

获取短信报表

var messageReport = new MessageReport();
var messageReportResult = client.GetMessagesReport(messageReport);

新增短信模板

var template = new Template(/*一些参数*/);
var templateResult = client.AddTemplate(template);

确定短信是否发送成功

在返回的对象中,包含着StatusCodeerror_code这两个属性,StatusCode是枚举类型HttpStatusCode:

var result = client.SendMessages(message);
if ( result.StatusCode == HttpStatusCode.OK && error_code != null ) {
    // 发送成功
} else {
    // 发送失败
    // result.error_code和result.message包含着错误信息。
}

提示

在解决方案中有实际操作例子。

upyun-sms-sdk's People

Contributors

leoskey avatar

Watchers

 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.