This sample demonstrates how to receive a message from the web through ODBC connection.
Files used in this sample are located in the folder:
C:\Program Files\CodeSegment\SMS Studio\Samples\ODBCConnection
How to run this sample
Source code
The contents of the receive_sms.asp file:
<%
'-------------------------------------------------------------------------------------------------------------------------------
' This script demonstrates how to receive a message message from the web through ODBC connection.
' After this script inserts a message into the database, the ODBC connection will collect it and store in the Inbox.
' WARNING: Error checking omitted for clarity.
' However, the remote computer will get the Ok response only after successful reception of a message.
'-------------------------------------------------------------------------------------------------------------------------------
AllowedIP = "127.0.0.1" ' Put the IP address of the remote computer allowed to send you messages
RemoteIP = Request.ServerVariables("REMOTE_ADDR") ' Take the address of the remote computer which tries to send you this message
RemoteIP = AllowedIP ' Delete or comment this line to enable the simple IP check
if RemoteIP = AllowedIP then
MsgText = Replace(Request("msg"),"'","''") ' A quote character may render an SQL query invalid
Sender = Replace(Request("from"),"'","''")
Recipient = Replace(Request("to"),"'","''")
set database = Server.CreateObject("ADODB.Connection")
database.Open "SMS ODBC Database"
database.Execute "INSERT INTO Incoming (RefID, MsgText, MsgType, Sender, Recipient) VALUES (0,'" & MsgText & "',0,'" & Sender & "','" & Recipient & "')"
database.Close
response.write("Ok") ' This line will not be executed in case of the failure
else
response.write("Not allowed.") ' Our simple IP check detected not allowed access
end if
'-------------------------------------------------------------------------------------------------------------------------------
' Copyright (c) 2002-2009 CodeSegment. All rights reserved. http://www.codesegment.com/
'-------------------------------------------------------------------------------------------------------------------------------
%>
| Copyright © 2002-2010 CodeSegment. All rights reserved. |