In this Article am describing how to integrate SMS API in C# that can send SMS to your mobile phone within Pakistan.
First go to this website and signup here
Here are the simple Steps that you follow :
First go to this website and signup here
Here are the simple Steps that you follow :
- First Launch a visual studio
- Create a console Application in visual studio
- After that first added assembly reference into your project
using System.Net;Here is Implementation
using System.Web;
using System; using System.Collections.Generic; using System.Linq; using System.Net; using System.Text; using System.Threading.Tasks; using System.Web; namespace ConsoleApp3 { class Program { static void Main(string[] args) { string MyUsername = "xxxx"; //Your Username At Sendpk.com string MyPassword = "xxxx"; //Your Password At Sendpk.com string toNumber = "xxxxx"; //Recepient cell phone number with country code string Masking = "Tech Spider"; //Your Company Brand Name string MessageText = "Application Done"; string jsonResponse = SendSMS(Masking, toNumber, MessageText, MyUsername, MyPassword); Console.Write(jsonResponse); //Console.Read(); //to keep console window open if trying in visual studio Console.ReadLine(); } public static string SendSMS(string Masking, string toNumber, string MessageText, string MyUsername, string MyPassword) { String URI = "http://Sendpk.com" + "/api/sms.php?" + "username=" + MyUsername + "&password=" + MyPassword + "&sender=" + Masking + "&mobile=" + toNumber + "&message=" + Uri.UnescapeDataString(MessageText); // Visual Studio 10-15 try { WebRequest req = WebRequest.Create(URI); WebResponse resp = req.GetResponse(); var sr = new System.IO.StreamReader(resp.GetResponseStream()); return sr.ReadToEnd().Trim(); } catch (WebException ex) { var httpWebResponse = ex.Response as HttpWebResponse; if (httpWebResponse != null) { switch (httpWebResponse.StatusCode) { case HttpStatusCode.NotFound: return "404:URL not found :" + URI; break; case HttpStatusCode.BadRequest: return "400:Bad Request"; break; default: return httpWebResponse.StatusCode.ToString(); } } } return null; } } }
Hello Zubair saif,
ReplyDeletehow are you?
bro i face a one error, and i don't know how to solve.
this code return [ Please Type Send ID]
i am trying with this code but it didn't work.
DeleteNice work Buddy ... Thanks a lot
ReplyDeleteThats of great help bro.
ReplyDeleteLoved it :)