public void SendMms()
        {
            var expectedJson = GetJsonPayload("/messaging/messagingApi/sendMms.json");
            var restRequest  = MockRestResponse(expectedJson);

            var now = DateTime.Now;
            var mms = new MmsMessage()
            {
                FileId      = 123,
                Subject     = "Subj",
                StampToSend = now
            };
            var response = Client.MessagingApi.Send(mms);

            EzTextingResponse <MmsMessage> ezResponse = new EzTextingResponse <MmsMessage>("Success", 201, response);

            Assert.That(Serializer.Serialize(ezResponse), Is.EqualTo(expectedJson));

            Assert.AreEqual(Method.POST, restRequest.Value.Method);
            Assert.IsTrue(restRequest.Value.Parameters.Count > 0);
            var bodyParam = restRequest.Value.Parameters[0];

            Assert.AreEqual(ClientConstants.FormEncodedContentType, bodyParam.ContentType);
            Assert.AreEqual(ParameterType.RequestBody, bodyParam.Type);

            Assert.That(bodyParam.Value, Is.StringContaining("User=login"));
            Assert.That(bodyParam.Value, Is.StringContaining("Password=password"));
            Assert.That(bodyParam.Value, Is.StringContaining("FileID=123"));
            Assert.That(bodyParam.Value, Is.StringContaining("Subject=Subj"));
            Assert.That(bodyParam.Value, Is.StringContaining("MessageTypeID=3"));
            Assert.That(bodyParam.Value, Is.StringContaining("StampToSend=" + ClientUtils.ToUnixTime(now) / 1000));
        }
示例#2
0
        public SmsService.SendMMSOutput Send(MmsMessage message)
        {
            //_smsInput.SHORT_NUMBER = "7023";

            _mmsInput.SHORT_NUMBER = message.ShortNumber;
            int messageCount = message.Recievers.Count;

            _mmsInput.TO_RECEIVERS = new string[messageCount];
            _mmsInput.MESSAGE_BODY = new string[messageCount];
            _mmsInput.SUBJECT      = message.Subject;
            _mmsInput.S_DATE       = message.SendDate;
            _mmsInput.EXPIRY_DATE  = message.ExpryDate;
            _mmsInput.MIME_DATA    = message.MimeData;

            for (int i = 0; i < messageCount; i++)
            {
                _mmsInput.TO_RECEIVERS.SetValue(message.Recievers[i], i);
                // _smsInput.TO_RECEIVERS.SetValue("905330000000", 0);
                //_smsInput.MESSAGE_BODY.SetValue("Bu bir test mesajıdır!", 0);
                // _wapPushInput.MESSAGE_BODY.SetValue(message.MessageBody[0], i);

                _transactionList[0] = "64324423";
            }
            SmsGatewayTurkcell.SmsService.SendMMSOutput output = _smsClient.SendMMS(_smsToken, _transactionList, _mmsInput);

            _smsClient.Close();
            return(output);
        }
 protected void OnMessagePrepared(MmsMessage message)
 {
     if (MessagePrepared != null)
     {
         MessagePrepared(this, new MessagePreparedEventArgs(message));
     }
 }
示例#4
0
        private static void GprsProvider_MmsBearerStateChanged(bool isOpen)
        {
            if (isOpen)
            {
                // launch a new thread to...
                new Thread(() =>
                {
                    // set MMS configuration
                    SIM800H.MmsConfiguration = new MmsConfiguration(mmsUrl, mmsProxy, mmsPort);

                    // build and send MMS message

                    // for this example we are reading the image from the application Resources
                    // in a real world application this could be stored in memory, SD card or any other storage media that can be read as a stream (image is optional)
                    // text for message is a string (is optional)
                    // title is a string (is optional)
                    MmsMessage msg = new MmsMessage(mmsText, Resources.GetBytes(Resources.BinaryResources.mmsImg), mmsTitle);

                    // make sure the GPRS bearer is opened before sending an MMS
                    // when sending an MMS there is an optional parameter to specify if the GPRS connection is to be closed after sending the message, this maybe relevant is your app needs to be power wise
                    SIM800H.MmsClient.SendMmsMessageAsync(mmsDestination, msg, true, (r) =>
                    {
                        // check if MMS was sent successfully
                        if (((SendMmsMessageAsyncResult)r).Result)
                        {
                            Debug.Print("MMS sent successfully!");
                        }
                        else
                        {
                            Debug.Print("### Error sending MMS. Error code: " + ((SendMmsMessageAsyncResult)r).ErrorCode.ToString() + " ###");
                        }
                    });
                }).Start();
            }
        }
示例#5
0
        public void Convert(string sInFile, string sOutFile)
        {
            List <WpMessage> mmses;

            using (XmlReader xr = XmlReader.Create(sInFile))
            {
                mmses = WpMessage.ReadMessagesFromXml(xr);

                xr.Close();
            }

            // ok, now we have a collection of messages...now we have to write them out...
            XmlWriterSettings xws = new XmlWriterSettings();

            xws.Indent = true;

            XmlWriter xw = XmlTextWriter.Create(sOutFile, xws);

            xw.WriteStartDocument();
            xw.WriteStartElement("smses");
            xw.WriteAttributeString("count", mmses.Count.ToString());
            int seqNo = 1;

            foreach (WpMessage wpm in mmses)
            {
                MmsMessage mms = MmsMessage.CreateFromWpMmsMessage(wpm, seqNo++);
                mms.WriteToDroidXml(xw);
            }

            xw.Flush();
            xw.Close();
            xw.Dispose();
        }
        public void BuildQueryParams()
        {
            var now = DateTime.Now;
            var mms = new MmsMessage
            {
                FileId  = 123,
                Subject = "test subject",
                Message = "this is mms message",
                Groups  = new List <string> {
                    "group1", "group2", "group3"
                },
                PhoneNumbers = new List <string> {
                    "1234567890", "2345678900", "3456789000"
                },
                StampToSend = now
            };

            var queryParams = ClientUtils.BuildQueryParams(mms).ToString();

            Console.WriteLine("params: " + queryParams);

            Assert.That(queryParams, Is.StringContaining("FileID=123"));
            Assert.That(queryParams, Is.StringContaining("Groups[]=group1"));
            Assert.That(queryParams, Is.StringContaining("Groups[]=group2"));
            Assert.That(queryParams, Is.StringContaining("Groups[]=group3"));
            Assert.That(queryParams, Is.StringContaining("PhoneNumbers[]=1234567890"));
            Assert.That(queryParams, Is.StringContaining("PhoneNumbers[]=2345678900"));
            Assert.That(queryParams, Is.StringContaining("PhoneNumbers[]=3456789000"));
            Assert.That(queryParams, Is.StringContaining("Subject=" + "test subject".UrlEncode()));
            Assert.That(queryParams, Is.StringContaining("Message=" + "this is mms message".UrlEncode()));
            Assert.That(queryParams, Is.StringContaining("MessageTypeID=3"));
            Assert.That(queryParams, Is.StringContaining("StampToSend=" + ClientUtils.ToUnixTime(now) / 1000));
        }
示例#7
0
 public Task <MmsMessage> Send(MmsMessage mms)
 {
     mms.MessageId = "123";
     SendMmsToMultipleNumberMethodWasCalled = true;
     NumbersSentTo = mms.PhoneNumbers.ToArray();
     MmsSent       = mms;
     return(Task.FromResult(mms));
 }
        /// <summary>
        /// Send message
        /// </summary>
        protected override async Task Send()
        {
            ClearErrorFile();
            IEnumerable <PhoneNumber> numbers = GetPhoneNumbers();
            var mms = new MmsMessage(numbers, Message, AttachmentFiles);

            OnMessagePrepared(mms);

            CurrentMessage = await _mmsService.Send(mms);
        }
        /// <summary>
        /// Sends MMS message to multiple recipients
        /// </summary>
        /// <param name="mms">MMS message to be sent.</param>
        /// <returns>Returns Task as a result of asynchronous operation. task result is <see cref="MmsMessage"/> sent MMS.</returns>
        /// <exception cref="System.ArgumentNullException">mms is null.</exception>
        public async Task <MmsMessage> Send(MmsMessage mms)
        {
            Argument.ExpectNotNull(() => mms);

            MmsResponse taskResp = await _mmsServiceWrapper.SendMms(mms.PhoneNumbers.Select(p => p.Number).ToList(), mms.Body, mms.Attachments);

            mms.MessageId = taskResp.Id;

            return(mms);
        }
示例#10
0
        /// <summary>
        /// Creates new instance of <see cref="MmsDeliveryListener"/>
        /// </summary>
        /// <param name="mmsService">Instance of <see cref="IMmsService"/></param>
        /// <param name="message">MMS message listen should check delivery status for.</param>
        /// <param name="pollPeriod">Time interval between delivery status polls.</param>
        /// <param name="timeout">If delivery status is not changed after this time interval then listener will stop polling.</param>
        public MmsDeliveryListener(
            IMmsService mmsService,
            MmsMessage message,
            TimeSpan pollPeriod,
            TimeSpan timeout)
            : base(message, pollPeriod, timeout)
        {
            Argument.ExpectNotNull(() => mmsService);

            _mmsService = mmsService;
        }
        /// <summary>
        /// Sends MMS message to multiple recipients
        /// </summary>
        /// <param name="mms">instance of <see cref="MmsMessage"/> to send</param>
        /// <returns>Returns Task as a result of asynchronous operation. Task result is generated message identifier.</returns>
        public Task <MmsMessage> Send(MmsMessage mms)
        {
            _mmsStatusRequestCount = 0;
            var  msgId   = new Guid().ToString();
            bool failMsg = mms.Body.IndexOf("fail", StringComparison.CurrentCulture) != -1;

            if (failMsg)
            {
                msgId += "fail";
            }
            mms.MessageId = msgId;

            return(Task.FromResult(mms));
        }
示例#12
0
文件: Program.cs 项目: ErinGQ/ym1623
        static void Main(string[] args)
        {
            MmsProtocolMm1 objMm1Protocol = new MmsProtocolMm1();
            MmsMessage     objMessage     = new MmsMessage();
            MmsSlide       objSlide       = new MmsSlide();
            MmsConstants   objConstants   = new MmsConstants();
            object         obj            = null;

            objSlide.Clear();
            objSlide.AddAttachment(ReadInput("选择需要发送的彩信文件(完整路径): ", false), ref obj);
            objSlide.AddText(ReadInput("输入文本内容(可选): ", true));

            objMessage.Clear();
            objMessage.AddRecipient(ReadInput("输入接收号码(号码必须以+86开头): ", false), objConstants.asMMS_RECIPIENT_TO);
            objMessage.Subject = ReadInput("输入彩信主提: ", true);
            obj = objSlide;
            objMessage.AddSlide(ref obj);

            objMm1Protocol.Device             = ReadDevice(objMm1Protocol);    //选择连接设备,注意发送彩信不可以直接连COM口
            objMm1Protocol.ProviderMMSC       = ReadInput("输入彩信中心: ", false);  //移动手机卡输入http://mmsc.monternet.com,联通手机卡输入http://mmsc.myuni.com.cn
            objMm1Protocol.ProviderAPN        = ReadInput("gprs接入点: ", false); //移动手机卡输入cmwap,联通手机卡输入UNIWAP
            objMm1Protocol.ProviderWAPGateway = ReadInput("网关地址: ", false);    //输入10.0.0.172
            objMm1Protocol.LogFile            = "c:\\mmsmm1.log";              //记录到日志

            // 连接
            objMm1Protocol.Connect();
            Console.WriteLine("正在连接...");
            Console.WriteLine("返回结果: " + objMm1Protocol.LastError + " (" + objMm1Protocol.GetErrorDescription(objMm1Protocol.LastError) + ")");
            if (objMm1Protocol.LastError != 0)
            {
                Console.WriteLine("Ready.");
                System.Threading.Thread.Sleep(3000);
                return;
            }

            // Send
            obj = objMessage;
            Console.WriteLine("正在发送...");
            objMm1Protocol.Send(ref obj);
            Console.WriteLine("返回结果: " + objMm1Protocol.LastError + " (" + objMm1Protocol.GetErrorDescription(objMm1Protocol.LastError) + ")");

            // Disconnect
            objMm1Protocol.Disconnect();
            Console.WriteLine("断开连接.");

            Console.WriteLine("Ready.");
            System.Threading.Thread.Sleep(3000);
        }
示例#13
0
文件: Program.cs 项目: ym1623/ym1623
        static void Main(string[] args)
        {
            MmsProtocolMm1 objMm1Protocol = new MmsProtocolMm1();
            MmsMessage objMessage = new MmsMessage();
            MmsSlide objSlide = new MmsSlide();
            MmsConstants objConstants = new MmsConstants();
            object obj = null;

            objSlide.Clear();
            objSlide.AddAttachment(ReadInput("选择需要发送的彩信文件(完整路径): ", false), ref obj);
            objSlide.AddText(ReadInput("输入文本内容(可选): ", true));

            objMessage.Clear();
            objMessage.AddRecipient(ReadInput("输入接收号码(号码必须以+86开头): ", false), objConstants.asMMS_RECIPIENT_TO);
            objMessage.Subject = ReadInput("输入彩信主提: ", true);
            obj = objSlide;
            objMessage.AddSlide(ref obj);

            objMm1Protocol.Device = ReadDevice(objMm1Protocol);//选择连接设备,注意发送彩信不可以直接连COM口
            objMm1Protocol.ProviderMMSC = ReadInput("输入彩信中心: ", false);//移动手机卡输入http://mmsc.monternet.com,联通手机卡输入http://mmsc.myuni.com.cn
            objMm1Protocol.ProviderAPN = ReadInput("gprs接入点: ", false);//移动手机卡输入cmwap,联通手机卡输入UNIWAP
            objMm1Protocol.ProviderWAPGateway = ReadInput("网关地址: ", false);//输入10.0.0.172
            objMm1Protocol.LogFile = "c:\\mmsmm1.log"; //记录到日志

            // 连接
            objMm1Protocol.Connect();
            Console.WriteLine("正在连接...");
            Console.WriteLine("返回结果: " + objMm1Protocol.LastError + " (" + objMm1Protocol.GetErrorDescription(objMm1Protocol.LastError) + ")");
            if (objMm1Protocol.LastError != 0)
            {
                Console.WriteLine("Ready.");
                System.Threading.Thread.Sleep(3000);
                return;
            }

            // Send
            obj = objMessage;
            Console.WriteLine("正在发送...");
            objMm1Protocol.Send(ref obj);
            Console.WriteLine("返回结果: " + objMm1Protocol.LastError + " (" + objMm1Protocol.GetErrorDescription(objMm1Protocol.LastError) + ")");

            // Disconnect
            objMm1Protocol.Disconnect();
            Console.WriteLine("断开连接.");

            Console.WriteLine("Ready.");
            System.Threading.Thread.Sleep(3000);
        }
        public void SendMms()
        {
            var msg = new MmsMessage
            {
                Message      = "my mms message",
                Subject      = "msg subject",
                FileId       = 22310,
                PhoneNumbers = new List <string> {
                    "4243876936", "2132212384"
                },
                StampToSend = DateTime.Now.AddMinutes(5)
            };

            var response = Client.MessagingApi.Send(msg);

            Console.WriteLine("send mms message response: " + response);
        }
        /// <summary>
        /// Send message
        /// </summary>
        protected override async Task Send()
        {
            ClearErrorFile();
            var attach = new List <StorageFile>();

            if (File != null)
            {
                attach.Add(File);
            }

            IEnumerable <PhoneNumber> numbers = GetPhoneNumbers();
            var mms = new MmsMessage(numbers, Message, attach);

            OnMessagePrepared(mms);

            CurrentMessage = await _mmsService.Send(mms);
        }
示例#16
0
        private static void GprsProvider_MmsBearerStateChanged(bool isOpen)
        {
            if (isOpen)
            {
                // launch a new thread to...
                new Thread(() =>
                {
                    // set MMS configuration
                    SIM800H.MmsConfiguration = new MmsConfiguration(mmsUrl, mmsProxy, mmsPort);

                    // build and send MMS message

                    // for this example we are reading the image from the application Resources
                    // in a real world application this could be stored in memory, SD card or any other storage media that can be read as a stream (image is optional)
                    // text for message is a string (is optional)
                    // title is a string (is optional)
                    MmsMessage msg = new MmsMessage(mmsText, Resources.GetBytes(Resources.BinaryResources.mmsImg), mmsTitle);

                    // make sure the GPRS bearer is opened before sending an MMS
                    // when sending an MMS there is an optional parameter to specify if the GPRS connection is to be closed after sending the message, this maybe relevant is your app needs to be power wise
                    SIM800H.MmsClient.SendMmsMessageAsync(mmsDestination, msg, true, (r) =>
                    {
                        // check if MMS was sent successfully
                        if (((SendMmsMessageAsyncResult)r).Result)
                        {
                            Debug.Print("MMS sent successfully!");
                        }
                        else
                        {
                            Debug.Print("### Error sending MMS. Error code: " + ((SendMmsMessageAsyncResult)r).ErrorCode.ToString() + " ###");
                        }
                    });

                }).Start();
            }
        }
示例#17
0
        private static bool ProcessCommand(string command)
        {
            bool continueLooping = true;

            if (command.Equals(HelpCommand, StringComparison.OrdinalIgnoreCase))
            {
                System.Console.WriteLine("Possible commands:");

                System.Console.WriteLine(SendSmsCommand + " <phone number> <message>");
                System.Console.WriteLine(GetSmsStatusCommand + " <sms id>");

                System.Console.WriteLine(SendMmsCommand + " <phone number> <message>");
                System.Console.WriteLine(GetMmsStatusCommand + " <mmsId id>");

                System.Console.WriteLine(ExitCommand);
            }
            else if (command.StartsWith(SendSmsCommand, StringComparison.OrdinalIgnoreCase))
            {
                string number  = GetArgument(command, 1);
                string message = GetArgument(command, 2);

                var phoneNumber = new PhoneNumber(number);
                var sms         = new SmsMessage(new List <PhoneNumber>()
                {
                    phoneNumber
                }, message);

                System.Console.WriteLine("Sending sms...");

                var        service = new AttSmsService(_endPoint, _apiKey, _secretKey);
                SmsMessage sentSms = service.Send(sms).Result;

                System.Console.WriteLine("SMS sent");
                System.Console.WriteLine("SMS id is {0}", sentSms.MessageId);
            }
            else if (command.StartsWith(GetSmsStatusCommand, StringComparison.OrdinalIgnoreCase))
            {
                string id    = GetArgument(command, 1);
                var    smsId = id;

                System.Console.WriteLine("Retrieving sms delivery status...");

                ISmsService service = new AttSmsService(_endPoint, _apiKey, _secretKey);
                var         status  = service.GetSmsStatus(smsId);

                System.Console.WriteLine("Status is {0}", status);
            }
            else if (command.StartsWith(SendMmsCommand, StringComparison.OrdinalIgnoreCase))
            {
                string number  = GetArgument(command, 1);
                string message = GetArgument(command, 2);

                var phoneNumber = new PhoneNumber(number);
                var mms         = new MmsMessage(new List <PhoneNumber>()
                {
                    phoneNumber
                }, message);

                System.Console.WriteLine("Sending mms...");

                var        service = new AttMmsService(_endPoint, _apiKey, _secretKey);
                MmsMessage sentMms = service.Send(mms).Result;

                System.Console.WriteLine("MMS sent");
                System.Console.WriteLine("MMS id is {0}", sentMms.MessageId);
            }
            else if (command.StartsWith(GetMmsStatusCommand, StringComparison.OrdinalIgnoreCase))
            {
                string id    = GetArgument(command, 1);
                var    mmsId = id;

                System.Console.WriteLine("Retrieving mms delivery status...");

                var service = new AttMmsService(_endPoint, _apiKey, _secretKey);
                var status  = service.GetMmsStatus(mmsId);

                System.Console.WriteLine("Status is {0}", status);
            }
            else if (command.Equals(ExitCommand, StringComparison.OrdinalIgnoreCase))
            {
                continueLooping = false;

                System.Console.WriteLine("Exiting. Please any key to close...");
                System.Console.Read();
            }
            else
            {
                System.Console.WriteLine("Command is not recognized. Type '{0}' for the list of allowed commands.", HelpCommand);
            }

            return(continueLooping);
        }
示例#18
0
 public abstract MmsMessageOutPut SendMmsMessage(MmsMessage message);