Save sent sms to the database

Save sent sms to the database SearchSearch
Author Message
Alessandro Guimarães
New member
Username: Inconnext

Post Number: 2
Registered: 04-2010
Posted on Wednesday, May 12, 2010 - 04:32 pm:   

I'm using the trial version of NowSMS and want to know how to write the SMS sent to the database access, I'm using ASP. can anyone help me?

Thanks
Des - NowSMS Support
Board Administrator
Username: Desosms

Post Number: 2102
Registered: 08-2008
Posted on Wednesday, May 12, 2010 - 07:14 pm:   

Hi Alessandro,

I am not sure what you are asking.

From your other posting (http://support.nowsms.com/discus/messages/1/59740.html), it appears that you have a 2-way command that is responding to messages.

Do you want to save the messages that your 2-way command sends to a database?

If so, then when you generate your response, your ASP script would also interface with your database.

I don't know what database you are using, but I'm sure a search will give some good suggestions: http://www.google.com/search?q=asp+database


If I have misunderstood your question, please clarify.

--
Des
NowSMS Support
Alessandro Guimarães
New member
Username: Inconnext

Post Number: 3
Registered: 04-2010
Posted on Wednesday, May 12, 2010 - 11:00 pm:   

Hi Des

Well let me explain if you want to know how to write sms sent to a database and how to do because if I create and write the script in ASP because I am a systems analyst.

As I said I could write the sms received in a database, using two-way the question is how do I save sent? is the same process?

below my script in asp to write sms received using 2-way:

<%
Response.ContentType = "text/plain"

Dim senderTxt, Prefix, Sms, Smstime, Smsdate, banco, conexao, rsConsulta

SenderTxt = Request.QueryString("sender")
Prefix = Request.QueryString("prefix")
Sms = Request.QueryString("message")
Smstime = Request.QueryString("time")
Smsdate = Request.QueryString("date")

Set Conexao = Server.CreateObject("ADODB.Connection")
Conexao.CursorLocation = 3 ' adUseClient
Conexao.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("db1.mdb")

set rsConsulta = server.createobject("adodb.recordset")

SQL = "INSERT INTO smstable (sender, perfix, sms, smstime, smsdate) VALUES ( '" & SenderTxt & "','" & Prefix & "','" & Sms & "','" & Smstime & "','" & Smsdate & "')"

Set rsConsulta = conexao.execute(SQL)

Response.Write ("Gravado com sucesso!")
%>

please give me a hint how can I do that?

I thank you,

Alessandro
Des - NowSMS Support
Board Administrator
Username: Desosms

Post Number: 2114
Registered: 08-2008
Posted on Thursday, May 13, 2010 - 04:10 pm:   

Hi Alessandro,

Maybe I am confused. Which of the following are you trying to do?

1.) Are you trying to save messages that you send as a response to the 2-way command?

2.) Or are you trying to save messages other messages that are sent?

If #1, then your ASP script is generating the message response, and it would save it in the same way that it is saving the inbound message.

If #2, it is possible to configure an "accounting callback", which can be an ASP script, that NowSMS calls every time a user submits a message. When NowSMS processes a message, it calls this "accounting callback" so that you can record details about messages being submitted (or block messages from being accepted). More details on the accounting callbacks can be found here: http://blog.nowsms.com/2009/01/dynamic-sms-message-routing-with-http.html

--
Des
NowSMS Support
Alessandro Guimarães
New member
Username: Inconnext

Post Number: 4
Registered: 04-2010
Posted on Thursday, May 13, 2010 - 04:31 pm:   

Hi Des

Sorry I did not express BEME in English, but understood. Good 2.) Option is the one I am willing to do the accounting of sms When NowSMS handles a message.

The link you sent me this response:

http://blog.nowsms.com/2009/01/dynamic-sms-message-routing-with-http.html

Thanks

Alessandro
Alessandro Guimarães
New member
Username: Inconnext

Post Number: 5
Registered: 04-2010
Posted on Thursday, May 13, 2010 - 06:16 pm:   

Link unanswered

http://blog.nowsms.com/2009/01/dynamic-sms-message-routing-with-http.html

Thanks

Alessandro
Des - NowSMS Support
Board Administrator
Username: Desosms

Post Number: 2120
Registered: 08-2008
Posted on Thursday, May 13, 2010 - 06:21 pm:   

Hi Alessandro,

I do not understand what your question is.

--
Des
NowSMS Support
Alessandro Guimarães
New member
Username: Inconnext

Post Number: 6
Registered: 04-2010
Posted on Thursday, May 13, 2010 - 06:33 pm:   

I want that all of the sent sms are recorded in the database

Thank you

Alessandro
Des - NowSMS Support
Board Administrator
Username: Desosms

Post Number: 2121
Registered: 08-2008
Posted on Thursday, May 13, 2010 - 07:42 pm:   

Ok Alessandro,

I understand we have a language difference so I will try to choose my words better.

To accomplish #2, you need to implement what we call an "accounting callback".

The link I sent you explains how "accounting callbacks" work in NowSMS.

The reason that it explains how these accounting callbacks work is different from the reason that you will want to use them.

They work the same way, whichever reason you have for using them.

The following article explains the basic "concept" of accounting callbacks:

http://www.nowsms.com/support/bulletins/tb-nowsms-001.htm

I like to direct people to the link that I sent you previously because it includes a more complete example of what an accounting callback looks like:

http://blog.nowsms.com/2009/01/dynamic-sms-message-routing-with-http.html

Why would you use "accounting callbacks" to accomplish #2?

Every time a user submits a message to NowSMS, NowSMS first performs the "PreAuth" callback. If you wanted to block some messages from being sent, you could do so with this callback, otherwise you ignore it.

When NowSMS accepts the message, it then performs an "SmsSend" callback. This callback provides details about the message being sent. If you implement this callback (which can be an ASP script), then this provides a way for you to record all outbound message traffic.

Hopefully this is more clear.

--
Des
NowSMS Support
Alessandro Guimarães
New member
Username: Inconnext

Post Number: 7
Registered: 04-2010
Posted on Saturday, May 15, 2010 - 06:11 pm:   

Hi Des,

Can you post myself an example of how to do the accounting callback sms?

Thanks

Alessandro
Des - NowSMS Support
Board Administrator
Username: Desosms

Post Number: 2132
Registered: 08-2008
Posted on Monday, May 17, 2010 - 08:29 pm:   

Hi Alessandro,

Refer again to that link that I posted earlier:

http://blog.nowsms.com/2009/01/dynamic-sms-message-routing-with-http.html

I'm going to assume that you will be working with ASP again.

Let's say that your ASP script is located at http://test/callback.asp.

The SMS Accouting callback URL is defined in the SMSGW.INI file, under the [SMSGW] section header:

SMSAccountingURL=http://test/callback.asp

Now, back to that link that I posted earlier.

Look at the section "SMSSend Accounting Callback".

The different variables mentioned under "SMSSend Accounting Callback" are parameters that you can access from your script using Request.QueryString.

The only other piece of advice that I have is that there are different types of callbacks. To save outbound messages, you want to use only the "SMSSend" callback.

What this means is this ...

If Request.QueryString("PreAuth") is "Yes", ignore the request because it is a pre-auth accounting callback.

If Request.QueryString("Type") is any value other than "SMSSend", ignore the request because it is a different type of accounting callback.

Does that explain it better?

--
Des
NowSMS Support