Пример #1
0
        public static bool CheckServiceStatus()
        {
            switch (Credential.ServiceName)
            {
            case "SwedishSms":
                return(true);    //cant test this

            case "SwedishKannel":
            {
                String   username = Credential.Login;
                String   password = Credential.Password;
                Encoding enc      = Credential.Encoding;
                String   url      = "https://nurse.sanitarium.se/kannel/status";
                String   result;

                HttpWebResponse responseOut = null;
                try
                {
                    result = HTTPSender.Send(url, enc, 1500, out responseOut);
                    if (((int)responseOut.StatusCode).ToString().StartsWith("2"))
                    {
                        return(true);
                    }
                    return(false);
                }
                catch (Exception)
                {
                    return(false);
                }
            }

            default:
                throw new Exception("Error on SMS transmit. Unknown SMS service: " + Credential.ServiceName);
            }
        }
Пример #2
0
        public static void SendKannel(string phoneNumber, string message)
        {
            //This is the swedish HOMEGROWN SMS sending mechanisma
            String encodedMessage = HttpUtility.UrlEncode(message, Credential.Encoding);
            String encodedPhone   = NormalizePhoneNumber(phoneNumber, Credential.Encoding);

            String   username = Credential.Login;
            String   password = Credential.Password;
            Encoding enc      = Credential.Encoding;
            String   url      = "https://nurse.sanitarium.se/sms/sendsms";
            String   call_string;
            String   result;

            call_string = url +
                          "?username="******"&password="******"&to=" + encodedPhone +
                          "&text=" + encodedMessage +
                          "&charset=latin1";

            result = HTTPSender.Send(call_string, enc);

            if (result != "0: Accepted for delivery")
            {
                throw new Exception("Error on SMS transmit: phone number " + phoneNumber + ", error code " + result);
            }
        }
Пример #3
0
        internal static void SendMoSMS(string phone, string message)
        {
            // This is the SWEDISH sms transmission mechanism.

            // Sätt användarnamn, lösenord och URL till MO-SMS.
            String   mosms_username = Credential.Login;
            String   mosms_password = Credential.Password;
            Encoding enc            = Credential.Encoding;
            String   mosms_url      = "http://www.mosms.com/se/sms-send.php";
            String   call_string;
            String   result;

            // Sätt mottagarens telefonnummer
            String mosms_number = phone;

            // Sätt vilken typ av SMS som skall skickas.
            String mosms_type = "text";

            String encodedMessage = HttpUtility.UrlEncode(message, Credential.Encoding);

            // Sätt SMS-meddelandet som skall skickas
            String mosms_data = encodedMessage;

            mosms_data = HttpUtility.UrlEncode(mosms_data, enc);

            call_string = mosms_url +
                          "?username="******"&password="******"&nr=" + mosms_number +
                          "&type=" + mosms_type +
                          "&data=" + mosms_data;

            result = HTTPSender.Send(call_string, enc);
            result = HttpUtility.UrlDecode(result, enc);

            if (result != "0")
            {
                throw new Exception("Error on SMS transmit: phone number " + phone + ", error code " + result);
            }
        }