Created
May 21, 2010 11:28
-
-
Save mcmarto/408726 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.IO; | |
using System.Net; | |
using System.Web; | |
namespace SMSConsole | |
{ | |
class Csoft | |
{ | |
#region CSoft class documentation | |
/// <summary> | |
/// This is an SMS/MMS provider class which acts as an interface for Connection Software's | |
/// corresponding web services (see http://www.csoft.co.uk for details) | |
/// </summary> | |
#endregion | |
private string userName; | |
private string PIN; | |
public Csoft() | |
{ | |
userName = "<YOUR USERNAME GOES HERE>"; | |
PIN = "<YOUR PIN GOES HERE>"; | |
} | |
public void SendSMS(string message, string recipients) | |
{ | |
WebClient client = new WebClient(); | |
System.Collections.Specialized.NameValueCollection queryParams = new System.Collections.Specialized.NameValueCollection(); | |
queryParams.Add("UN",userName); | |
queryParams.Add("PIN",PIN); | |
queryParams.Add("N",recipients); | |
queryParams.Add("M",message); | |
queryParams.Add("ResponseFormat","1"); | |
string uri = "https://www.csoft.co.uk/webservices/http/sendsms"; | |
client.Headers.Add("Content-Type", "application/x-www-form-urlencoded"); | |
client.Encoding = System.Text.Encoding.UTF8; | |
client.QueryString = queryParams; | |
byte[] response = client.UploadValues(uri, queryParams); | |
// Decode and display the response. | |
Console.WriteLine("\nResponse received was :\n{0}", Encoding.ASCII.GetString(response)); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment