11.07.2015 Views

Sample code for HTTP API

Sample code for HTTP API

Sample code for HTTP API

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>Sample</strong> <strong>code</strong> <strong>for</strong> <strong>HTTP</strong> <strong>API</strong> specification v2.3.013 April 2007


<strong>Sample</strong> Code <strong>for</strong> <strong>HTTP</strong> <strong>API</strong> specification v. 2.3.01. CFMPage 1.To:Message:Page 2.2. PHPCopyright © Clickatell, 2006 2


<strong>Sample</strong> Code <strong>for</strong> <strong>HTTP</strong> <strong>API</strong> specification v. 2.3.03. C#using System.Net;using System.IO;WebClient client = new WebClient ();// Add a user agent header in case the requested URI contains a query.client.Headers.Add ("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR1.0.3705;)");client.QueryString.Add("user", "xxxx");client.QueryString.Add("password", "xxxx");client.QueryString.Add("api_id", "xxxx");client.QueryString.Add("to", "xxxx");client.QueryString.Add("text", "This is an example message");string baseurl ="http://api.clickatell.com/http/sendmsg";Stream data = client.OpenRead(baseurl);StreamReader reader = new StreamReader (data);string s = reader.ReadToEnd ();data.Close ();reader.Close ();return (s);4. VB.NetImports System.NetImports System.IODim client As WebClient = New WebClient' Add a user agent header in case the requested URI contains a query.client.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR1.0.3705;)")client.QueryString.Add("user", "xxxx")client.QueryString.Add("password", "xxxx")client.QueryString.Add("api_id", "xxxx")client.QueryString.Add("to", "xxxx")client.QueryString.Add("text", "This is an example message")Dim baseurl As String = "http://api.clickatell.com/http/sendmsg"Dim data As Stream = client.OpenRead(baseurl)Dim reader As StreamReader = New StreamReader(data)Dim s As String = reader.ReadToEnd()data.Close()reader.Close()Copyright © Clickatell, 2006 3


<strong>Sample</strong> Code <strong>for</strong> <strong>HTTP</strong> <strong>API</strong> specification v. 2.3.0Return s5. VBScriptDim sUrl,Dim s<strong>API</strong>_ID, sPassword, sUsername, sMobileNo, sTextDim oXML<strong>HTTP</strong>, sPostData, sResultsUrl = "http://api.clickatell.com/http/sendmsg"s<strong>API</strong>_ID = "xxxx"sPassword = "xxxx"sUsername = "xxxx"sMobileNo = "xxxx"sText = "This is an example message"sPostData = "api_id=" & s<strong>API</strong>_IDsPostData = sPostData & "&user=" & sUsernamesPostData = sPostData & "&password=" & sPasswordsPostData = sPostData & "&to=" & sMobileNosPostData = sPostData & "&text=" & sTextSet oXML<strong>HTTP</strong> = Server.CreateObject("Microsoft.XML<strong>HTTP</strong>")oXML<strong>HTTP</strong>.Open "POST", sUrl, falseoXML<strong>HTTP</strong>.SetRequestHeader "Content-Type", "application/x-www-<strong>for</strong>m-urlen<strong>code</strong>d"oXML<strong>HTTP</strong>.Send sPostDatasResult = oXML<strong>HTTP</strong>.responseTextSet oXML<strong>HTTP</strong> = nothingResponse.Write sResultPlease note that some of the above <strong>code</strong> has been supplied to Clickatell by clients. As such accuracyis not guaranteed by Clickatell6. CONTACT DETAILS:Phone: +27 21 910 7700Fax: +27 21 910 7701Website: www.clickatell.comHelp URL: http://support.clickatell.com/index.phpSupport: support@clickatell.comSales: sales@clickatell.comCopyright © Clickatell, 2006 4

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!