Sample Code
This code example demonstrates how to deliver a WAP Push
message using the SMPP SDK™ and the MercuryXMS™ WAP Push SDK™.
This example is written in Visual Basic - samples are
available in C#, VB.NET and C++.
[Visual Basic]
'Gather the connection
details and create a connection to the SMSC
'Connect to the SMSC at on port 8100
lResult = objSMPP.SocketConnect("", 8100,
0)
If (lResult <> 0) Then
sMsg = "Failed to connect to on port 8100" & vbLf & vbLf
sMsg = sMsg & "Result: " & CStr(lResult) & vbLf & vbLf
sMsg = sMsg & "Check your connection details and try again." & vbLf &
vbLf
MsgBox sMsg, vbInformation
Exit Sub
End If
'Bind to that connection with your
username/password details
objSMPP.SetLicenseKey ("") 'Licensed users set your
license key here!
objSMPP.SMSCResponseTime = 10000
lResult = objSMPP.SMSCBind("", "SMS", 1, 1, 3,
"PASSWORD", "", 0)
If (lResult <> 0) Then
sMsg = "Failed to bind to the connection. Check your connection."
MsgBox sMsg, vbInformation
Exit Sub
End If
'Compose the WAP Push message
Dim objWAPPush As New ServiceIndicationMessage
'Specify the text to appear on the
handset
objWAPPush.MessageText = "Your ringtone"
'Specify the location of the conten
objWAPPush.URI = "http://www.mysite.com/polyphonic.midi"
'Specify the alert level
objWAPPush.Action = si_SignalMedium
'Specify a unique ID
objWAPPush.Identifier = Format(Now, "yyyymmddhhmmss")
'Generate the PDUs
objWAPPush.GeneratePDU
'Now send each PDU (in this case it will
only be one but MercuryXMS
'automatically handles concatenation so to use a For Each loop
'is a little more elegant.
'Send the PDUs
For Each objPDU In objWAPPush.PDUs
lResult = objSMPP.SMSCSubmitMessage("", "Sender",
16, 1, 1, 1, 1, objPDU.UserData, Now(), 48)
If (lResult <> 0) Then
MsgBox "Error sending user data: " & CStr(lResult), vbInformation
Else
Debug.Print "PDU sent: Receipt number is " & objSMPP.SMSCMessageID
End If
Next
'Close the connection and clean up
objSMPP.SMSCUnbind
objSMPP.SocketDisconnect