Sends the SMS. (发送短信)

REST API: http://yunpian.com/v1/sms/send.json
Code sample: [Please change api key with your own in your codes] (示例代码: [请在你自己的代码里修改你自己的api key的值)]
 class Program
{
    /// <summary>
    /// Defines the entry point of the application.
    /// </summary>
    /// <param name="args">The arguments.</param>
    /// <exception cref="System.InvalidOperationException">Failed to send SMS by template</exception>
    static void Main(string[] args)
    {
        // Need to replace with your own API key here.
        // 此处的值需要被替换成你自己的API Key
        const string yourApiKey = "YourApiKey";

        // Create instance of API client.
        // 创建 API Client 实例
        ApiClient client = new ApiClient(yourApiKey);

        // Create SMS instance for sending
        // 创建要发送的SMS 实例
        var sms = new ShortMessage
        {
            // Set cellphone number of receiver
            // 填写收信人手机号
            Destination = "13800138000",
            // Set content, which is ended by your company identity.
            // 填写正文内容, 并以公司标识结尾
            Content = "您的验证码是1234【云片网】"
        };

        // Send SMS and get response
        // 发送短信并获得响应
        var response = client.SendSMS(sms);

        // Check if any error occurred.
        // 检查是否有错误
        if (response == null || response.Code != 0)
        {
            throw new InvalidOperationException("Failed to send SMS");
        }

        // Print response data for fee, id and count
        // 打印返回的费用, ID和发送的记录条数
        Console.WriteLine("Fee: {0}, ID: {1}, Count: {2}", response.Data.Fee, response.Data.Id, response.Data.Count);
    }
}

Last edited Sep 26, 2014 at 4:08 AM by rynnwang, version 1