Docy

Did You Know?

C# Sample Code (GET)

                                        
                                            
                                           
                                          using System;
                                            using System.Collections.Generic;
                                            using System.Net;
                                            using System.Collections.Specialized;
                                            using System.IO;
                                            
                                            namespace sendSMS
                                              {
                                                    class sendSMS
                                                {
                                                        public string sendSMS()
                                                    {
                                                        String result;
                                                        string apiKey = "your apiKey";
                                                        string numbers = "923186373741,923186373741,923186373741"; // in a comma seperated list
                                                        string message = "This is your message";
                                                        string sender = "Jims Autos";
                                                
                                                        String url = "https://www.echosofts.com/api/sendsms.php?apikey=" + apiKey + "&phone=" + numbers + "&message=" + message + "&sender=" + sender;
                                                        //refer to parameters to complete correct url string
                                                
                                                        StreamWriter myWriter = null;
                                                        HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create(url);
                                                
                                                        objRequest.Method = "POST";
                                                        objRequest.ContentLength = Encoding.UTF8.GetByteCount(url);
                                                        objRequest.ContentType = "application/x-www-form-urlencoded";
                                                        try
                                                {
                                                   myWriter = new StreamWriter(objRequest.GetRequestStream());
                                                   myWriter.Write(url);
                                                }
                                                      catch (Exception e)
                                                    {
                                                       return e.Message;
                                                    }
                                                       finally
                                                    {
                                                       myWriter.Close();
                                                    }
                                            
                                                HttpWebResponse objResponse = (HttpWebResponse)objRequest.GetResponse();
                                                using (StreamReader sr = new StreamReader(objResponse.GetResponseStream()))
                                                {
                                                    result = sr.ReadToEnd();
                                                    // Close and clean up the StreamReader
                                                    sr.Close();
                                                }
                                                      return result;
                                                    }
                                                }
                                            }
                                                
                                           
                                        
                                    

C# Sample Code (POST)

                                        
                                        
                                            using System;
                                        using System.Collections.Generic;
                                        using System.Net;
                                        using System.Collections.Specialized;
                                        
                                        namespace sendSMS
                                        {
                                            class sendSMS
                                            {
                                                public string sendSMS()
                                                {
                                                    String message = HttpUtility.UrlEncode("This is your message");
                                                    using (var wb = new WebClient())
                                                    {
                                                        byte[] response = wb.UploadValues("https://www.echosofts.com/api/sendsms.php", new NameValueCollection()
                                                        {
                                                        {"apikey" , "yourapiKey"},
                                                        {"phone" , "923186373741,923186373741,923186373741"},
                                                        {"message" , message},
                                                        {"sender" , "Jims Autos"}
                                                        });
                                                        string result = System.Text.Encoding.UTF8.GetString(response);
                                                        return result;
                                                    }
                                                }
                                            }
                                        }
                                        
                                         
                                    

CONTENTS