public static MessageStatus StaticSendMessage(string from, string to, string message)
        {
            var textModel = new TextRequestModel { Text = message };
             var username = "******";
             var password = "******";

             var requestModel = RequestModelBuilder.Create(username, password, from, to, textModel);
             var nexmo = new Nexmo_CSharp_lib.Nexmo();
             JsonResponseModel responseModel = nexmo.Send(requestModel, ResponseObjectType.Json) as JsonResponseModel;
             var msg = responseModel.MessageModels.First();
             var status = msg.Status;
             var sent = msg.Status.Equals("Success", StringComparison.InvariantCultureIgnoreCase) ? true : false;
             var sentDate = DateTime.Now.ToUniversalTime();
             //DA: atm, when sending the message via nexmo we don't receive the sent date (or created date) so we use the current datestamp of the server (UTC format)
             var response = new MessageStatus() { MessageSent = sent, DateSent = sentDate, Status = status, ExternalID=msg.MessageId,Price=msg.MessagePrice };
             return response;
        }
Ejemplo n.º 2
0
        private static void JsonExample()
        {
            Log.Info("- JsonExample -");

            var textModel = new TextRequestModel {Text = "HelloWorld!"};

            var requestModel = RequestModelBuilder.Create("{USERNAME}", "{PASSWORD}", "{FROM}", "{TO}", textModel);

            var nexmo = new Nexmo();

            var responseModel = nexmo.Send(requestModel, ResponseObjectType.Json);

            Log.Info("- Result -");
            responseModel.ReadObject();

            Log.Info("- End -");
        }