- Quick Start Guide
- System requirements
- Installation guide
- Mobile networks
- User guide
- Developers guide
- SMS from SQL
- HTTP API
- PHP SMS API
- C# SMS API
- C# SMS script
- API reference guide
- C# to MSSQL
- VB.NET SMS API
- Service providers
C# SMS API reference
'SMSClient' is the namespace of the C# SMS API's class.
Add the following line to include it:
'using SMSClient;'. On this page you can find useful properties, methods and events. By modifying the properties you can log into Ozeki SMS Gateway to send and receive SMS.
'mySMSClient' will be the name of the C# instance used in this reference guide.
ozSMSClient mySMSClient = new ozSMSClient();
- Username: The name of the SMS Gateway user you would like to use for login. Default value: admin
- Password: The password belonging to the username. Default value: abc123
- Host: The IP address of your Ozeki SMS Gateway. Default value: 127.0.0.1
- Port: The port number of Ozeki SMS Gateway's SMPP server. Default value: 9500
- Connected: You can build up a connection by changing this bool value to true. Default value: false
- KeepalivePeriod: The time to wait in seconds between pinging the SMPP server. Default value: 60
- SocketTimeout: The time span to spend on waiting for the login PDU (in seconds). Default value: 10
mySMSClient.Username = "admin"; mySMSClient.Password = "abc123"; mySMSClient.Host = "127.0.0.1"; mySMSClient.Port = 9500; mySMSClient.Connected = true;
|sendMessage||You can easily send SMS messages with this method. The recipient's phone number and the text message are mandatory parameters. You can see the parameters of 'sendMessage' by checking out this page.|
mySMSClient.sendMessage("+3620123456","Hello world", "param1=value1&"+ "vp=2018.07.26.+10%3A07%3A58&"+ "param3=value3");
|sendMessageEx||It contains extra parameters compared to 'sendMessage', although both are capable to send SMS messages. All parameters are mandatory, but you can use "" or NULL at the following parameters: sender, serviceprovider and optionalParameterList.|
Dictionary<string, string> HelloWorld_parameters = new Dictionary<string, string>(); HelloWorld_parameters.Add("param1", "value1"); HelloWorld_parameters.Add("vp", "2018.07.26.+10%3A07%3A58"); HelloWorld_parameters.Add("param3", "value3"); mySMSClient.sendMessageEx("+3670654321", "+3620123456", "Hello world", "SMS:TEXT", "SMPP0", HelloWorld_parameters);
'mySMSClient' is an example created with the constructor.Events connected to mySMSClient
mySMSClient.OnClientConnected += new SimpleEventHandler (mySMSClient_OnClientConnected); mySMSClient.OnClientDisconnected += new SimpleEventHandler (mySMSClient_OnClientDisconnected); mySMSClient.OnClientConnectionError += new ErrorEventHandler (mySMSClient_OnClientConnectionError); mySMSClient.OnMessageAcceptedForDelivery += new DeliveryEventHandler (mySMSClient_OnMessageAcceptedForDelivery); mySMSClient.OnMessageDeliveredToNetwork += new DeliveryEventHandler (mySMSClient_OnMessageDeliveredToNetwork); mySMSClient.OnMessageDeliveredToHandset += new DeliveryEventHandler (mySMSClient_OnMessageDeliveredToHandset); mySMSClient.OnMessageDeliveryError += new DeliveryErrorEventHandler (mySMSClient_OnMessageDeliveryError); mySMSClient.OnMessageReceived += new DeliveryEventHandler (mySMSClient_OnMessageReceived);
Events can be shown on the console of your C# application (Figure 1).
Figure 1 - An 'OnClientConnected' event
Now look at the detailed description of each event on the table below:
|OnClientConnected||This event is invoked by your C# application if the connection to the SMPP server of Ozeki SMS Gateway was successful.|
|OnClientDisconnected||It is invoked if your C# application was disconnected from the SMPP server of Ozeki SMS Gateway.|
|OnClientConnectionError||It is invoked by your C# application if the connection to the SMPP server of Ozeki SMS Gateway was unsuccessful.|
|OnMessageAcceptedForDelivery||It is invoked if the message is accepted for delivery by Ozeki SMS Gateway through a user. The SMS Gateway user must be connected to your C# application and the user must have enough SMS credits as well.|
|onMessageDeliveredToNetwork||It is invoked if the GSM network provider accepts the SMS message for delivery.|
|onMessageDeliveredToHandset||It is invoked exactly when the SMS message reaches the recipient's mobile phone. The phone can be out of coverage or can also be turned off, so this event might happen long after the 'onMessageDeliveredToNetwork' event.|
Message delivery error can happen in 3 different situations:
1. There is no recipient with the selected phone number.
2. There is no money on the sender's account.
3. It has been stored on the GSM server for more time then the validity period.
|onMessageReceived||Your Ozeki SMS Gateway can receive SMS messages too. In this case an 'onMessageReceived' event will be invoked for your C# application. This happens exactly when the message is received by a user of Ozeki SMS Gateway. This user must be connected to the C# SMS API.|