Navigation: How to... > Scripting examples > Gateway scripting examples >
The BulkSMS.com gateway script provides a connection to the bulksms.com SMS gateway. The script offers support for sending text, unicode and flash SMS messages. Status update requests are also supported, making it possible to see when a message is received on the GSM phone.
You can find the BulkSMS.com.cs script in the Examples folder of Diafaan SMS Server.
The script makes use of the System.Web assembly so System.Web.dll has to be added to the ReferenceList property in the Advanced tab page.
Before you can use the script you have to change the userName and password variables in the top of the script.
In the OnMessageToSend event method the query string is built with different parameters depending on the message type. The binary message type is not supported but it will not be very difficult to implement this as well. The query string is sent with a POST method to the url using an HttpWebRequest.
If the response indicates that the message is successfully sent, the script calls PostSendResult with a positive status code, the last parameter of this call is set true. This instructs Diafaan SMS Server to fire the OnStatusRequest event one or more times depending on the message status.
If the response does not indicate that the message is successfully sent, the script calls PostSendResult with a negative status code.
If you make any change to the script make sure that the PostSendResult is always called, even if an exception is caused. Otherwise the script will only continue with the next message after a timeout of several minutes.
Status updates are handled in the OnStatusRequest event. The script sends an HTTP query to BulkSMS.com and calls PostSendResultUpdate if the response indicates that the message was received on the GSM phone. In this case OnStatusRequest is not called again.
If the response does not indicate that the message was received on the GSM phone the OnStatusRequest event will be called a couple of times more, each time with a larger time interval.
Permanent errors are not handled in the example script, but it is possible to use PostSendResultUpdate for permanent errors as well.