This method allows you to send a single text message to a cell phone. Any replies made to the number will be sent to the default reply path set up on the username provided.
Any query string parameters provided on the reply path will be included on the reply call. The following placeholders will be replaced by MercurySend if provided:
An example of a HTTPPOST/HTTPGET reply path is: http://www.yourdomain.com/Receive.aspx?From=#FROMCELL#&To=#TOCELL#&Message=#MSG#&ReceivedTime=#RECVTIME#
string username = "[USERNAME]"; string password = "[PASSWORD]"; string recipients = "[RECIPIENTS]"; string message = "[MESSAGE]"; string replyType = null; // Can be EMAIL, HTTPPOST and HTTPGET string replyPath = null; // Can be email address for ReplyType = EMAIL, or URL for HTTPPOST/HTTPGET // For HTTPPOST/HTTPGET replyPath = "http://www.yoururl.com/Receive.aspx?From=#FROMCELL#&To=#TOCELL#&Message=#MSG#&ReceivedTime=#RECVTIME#" StringBuilder sb = new StringBuilder(); sb.Append("Username=" + HttpUtility.UrlEncode(username)); sb.Append("&Password=" + HttpUtility.UrlEncode(password)); sb.Append("&Recipients=" + HttpUtility.UrlEncode(recipients)); sb.Append("&Message=" + HttpUtility.UrlEncode(message)); if (!string.IsNullOrEmpty(replyType)) { sb.Append("&ReplyType=" + replyType); } if (!string.IsNullOrEmpty(replyPath)) { sb.Append("&ReplyPath=" + HttpUtility.UrlEncode(replyPath)); } HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://api.mercurysend.com/1.0/send?" + sb.ToString()); string jsonResponse = null; request.Method = "GET"; request.Accept = "application/json"; using (HttpWebResponse httpResponse = (HttpWebResponse)request.GetResponse()) { using (StreamReader reader = new StreamReader(httpResponse.GetResponseStream())) { jsonResponse = reader.ReadToEnd(); } }
{ "Result": { "Success":true, "Code":0 }, "MessageIds":[] }
{ "Result": { "Success":false, "Description":"Error description", "Code":1 } }
Indicates that the message was lodged succesfully
Indicates that the message failed due to insufficient credits on the account
Indicates that the message failed due to insufficient daily credits remaining on the senders login
Indicates that the message failed due to invalid arguments being sent in
Indicates that the message failed due to the senders account not yet being verified
Indicates that the message failed due to the senders account having outstanding orders