/// <summary> /// Check to see if the given phone digits are /// indeed a cell phone. /// </summary> /// <param name="user">The user identity (api key) to authenticate with the provider.</param> /// <param name="password">The user password (secondary key) to authenticate with the provider.</param> /// <param name="digits">The phone number digits to check for a cell.</param> /// <returns>Indicates whether or not the digits are a cell.</returns> public bool IsACell(string user, string password, string digits) { if (String.IsNullOrEmpty(user)) { this.ApplyResponse(HttpStatusCode.InternalServerError, "Client api key not configured."); return(false); } HttpPostAdapter adapter = new HttpPostAdapter(String.Format("{0}{1}", sdetech.Default.api_base_url, sdetech.Default.confirm_method_name)); adapter.AppendPostParameter("ApiKey", user); adapter.AppendPostParameter("PhoneNumber", String.Format("{0}", digits)); string response = null; try { response = adapter.Post(); } catch (Exception ex) { this.PostEntry("SYSTEM:ERROR", String.Format("Problem confirming number as a cell phone: {0}", ex.Message)); this.ApplyResponse(HttpStatusCode.InternalServerError, "Problem confirming number as a cell phone."); return(false); } return(this.CheckConfirmation(digits, response)); }
/// <summary> /// Send a messsage to a cell recipient. /// </summary> /// <param name="user">The user identity (api key) to authenticate with the provider.</param> /// <param name="password">The user password (secondary key) to authenticate with the provider.</param> /// <param name="to">The cell phone number to send the message to.</param> /// <param name="from">The long or short code to send the message from.</param> /// <param name="message">The SMS message content.</param> /// <param name="reference">An optional reference to associate and keep with the message.</param> /// <param name="note">An optional note to associate and keep with the message.</param> /// <returns>Indicates the success or failure of the send.</returns> public bool Send(string user, string password, string to, string from, string message, string reference, string note) { if (String.IsNullOrEmpty(user)) { this.ApplyResponse(HttpStatusCode.InternalServerError, "Client api key not configured."); return(false); } HttpPostAdapter adapter = new HttpPostAdapter(String.Format("{0}{1}", sdetech.Default.api_base_url, sdetech.Default.send_method_name)); adapter.AppendPostParameter("ApiKey", user); adapter.AppendPostParameter("PhoneNumber", to); adapter.AppendPostParameter("FromSMS", String.Format("{0}", from)); adapter.AppendPostParameter("ClientUserId", reference); adapter.AppendPostParameter("Message", message); string response = null; try { response = adapter.Post(); } catch (Exception ex) { this.PostEntry("SYSTEM:ERROR", String.Format("Problem dispatching message: {0}", ex.Message)); this.ApplyResponse(HttpStatusCode.InternalServerError, "Problem dispatching message. It was not delivered."); return(false); } if (String.IsNullOrEmpty(response)) { this.ApplyResponse(HttpStatusCode.InternalServerError, adapter.AccquireLastError()); return(false); } if (this.DispatchFailed(response)) { return(false); } adapter.Clear(); return(true); }