Пример #1
0
        private void sendButtonClicked(object sender, EventArgs ea)
        {
            Toast.MakeText(this, "Sending SMS...", ToastLength.Short).Show();

            TextView fromView = FindViewById <TextView>(Resource.Id.editTextFrom);
            TextView toView   = FindViewById <TextView>(Resource.Id.editTextTo);

            String from = fromView.Text;
            String to   = toView.Text;

            RadioGroup radios = FindViewById <RadioGroup>(Resource.Id.radioGroup1);

            switch (radios.CheckedRadioButtonId)
            {
            case Resource.Id.radioButtonNexmo:
                service = new Nexmo(
                    this,
                    "[Nexmo Client ID]",
                    "[Nexmo Client Secret]"
                    );
                break;

            case Resource.Id.radioButtonTwilio:
                service = new Twilio(
                    this,
                    "[Twilio Client ID]",
                    "[Twilio Client Secret]"
                    );
                break;

            case Resource.Id.radioButtonTwizo:
                service = new Twizo(
                    this,
                    "[Twizo Key]"
                    );
                break;
            }


            new System.Threading.Thread(new System.Threading.ThreadStart(() =>
            {
                // run in background

                service.SendSMS(
                    from,
                    to,
                    "CloudRail is awesome!"
                    );
                RunOnUiThread(() => {
                    Toast.MakeText(this, "SMS was send", ToastLength.Short).Show();
                });
            })).Start();
        }
Пример #2
0
    public string SendSMS(string UserName, string UserPass, string Destination, string SMContent)
    {
        string[] dest;

        if (UserName == "")
        {
            return(_ERR_USERISEMPTY);
        }

        if (UserPass == "")
        {
            return(_ERR_PASSISEMPTY);
        }

        if (Destination == "")
        {
            return(_ERR_DESTISEMPTY);
        }
        else
        {
            dest = Regex.Split(Destination, ",");
            if (dest.Count() > 100)
            {
                return(_ERR_DESTTOLONG);
            }
        }

        ISMS interface_sms = (ISMS)Activator.GetObject(typeof(ISMS), ConfigurationManager.AppSettings["Pretreatment"]);
        SMS  model_sms     = new SMS();

        // 是否审核
        model_sms.Audit = AuditType.Manual;
        // 是否过滤
        model_sms.Filter = FilterType.Failure;
        // 消息级别
        model_sms.Level = LevelType.Level0;
        // 用户名
        model_sms.Account = UserName;
        // 短信内容
        model_sms.Content  = SMContent;
        model_sms.SPNumber = "";
        // 接收短信的号码
        List <string> num = new List <string>();

        foreach (string destnum in dest)
        {
            num.Add(destnum);
        }
        model_sms.Number       = num;
        model_sms.SendTime     = DateTime.Now;
        model_sms.SerialNumber = Guid.NewGuid();
        // 是否需要短信报告
        model_sms.StatusReport = StatusReportType.Enabled;
        // 通道类型
        model_sms.Channel = ChannelType.Industry;

        // 发送短信
        RPCResult <Guid> r = interface_sms.SendSMS(model_sms);

        SendSMSResult ret = new SendSMSResult();

        ret.Result = r.Message;
        ret.MsgId  = r.Value.ToString();
        string data = JsonSerialize.Serialize <SendSMSResult>(ret);

        return(data);
    }
Пример #3
0
 public void sendMessage()
 {
     sms.SendSMS(tw.GetTweet(), phoneNumber);
 }