**>To: [email protected]
**>From: Henry Junior <[EMAIL PROTECTED]>
**>Subject: Sending an SMS out of Asterisk via Kannel
**>Date: Mon, 18 Jul 2005 13:36:15 -0400
**>
**>GOAL: To pass variables from Asterisk to Kannel when sending out an
**>SMS message using a URL.
**>
**>CURRENTLY: I am able to pass a URL via Asterisk to Kannel and out of
**>my GSM modem BUT I haven't figured out how to include Asterisk
**>variables in the string.
**>
**>I was hoping someone could help me figure out what I'm doing wrong.
**>Perhaps there is a simple AGI I should be using. I am not extremely
**>comfortable writing AGIs but I suppose if I had a great example to
**>modify I could figure it out.
**>
**>Main objective at the moment would be to just modify slightly what I
**>am doing here to pass the variable.
**>
**>WORKING EXAMPLES:
**>This code works when I don't attempt to pass an Asterisk variable, in
**>other words when it's just text in the message:
**>
**>exten => s,9,System(curl "http://127.0.0.1:13370/cgi-bin/sendsms?
**>username=name&password=pass&to=12122122121&from=12122121212&text=Message
**>+text+here")
**>
**>NON WORKING EXAMPLES:
**>When I attempt to pass an Asterisk variable this code does not work:
**>
**>exten => s,9,System(curl "http://127.0.0.1:13370/cgi-bin/sendsms?
**>username=name&password=pass&to=12122122121&from=12122121212&text=Message
**>+text+here+${CALLERIDNUM}")
**>
**>I realize this isn't the most elegant flow. Suggestions are
**>welcome. I was wondering what am I doing wrong in this case though?
**>
**>Thanks for your time and feedback.
Not really a Kannel question ... more of an Asterisk question...
There's nothing wrong with your non-working example except for the
assumption of ${CALLERIDNUM} always returns just digits. It could
return a space character that will screw up the URL.
Check your smsbox logs to verify that Asterisk successfully issued
the HTTP_GET via curl.
Also, add some NoOp() to the dialplan to see the value of
${CALLERIDNUM} that's being passed through to curl. Run asterisk
in debug mode with massive verbose settings (-vvvvvgcn) so you
can see the exact execution path.
This is a working example Macro that prompts for 2 PIN numbers and then
uses Kannel to send an SMS:
[macro-two-pins-in-sms]
exten => s,1,Answer
exten => s,2,Wait(1)
exten => s,3,Read(firstnum|agent-pass|5)
exten => s,4,Read(secondnum|vm-reenterpassword|5)
exten => s,5,NoOp(firstnum=${firstnum}, secondnum=${secondnum},
CALLERIDNUM=${CALLERIDNUM})
exten => s,6,System(/tmp/curl.sh
"http://127.0.0.1:13013/cgi-bin/sendsms?usernamename&password=pass&to=12122122121&from=12122121212&text=Message+${TIMESTAMP}+${firstnum}+${secondnum+${CALLERIDNUM}");
exten => s,7,Playback(vm-goodbye)
exten => s,8,Hangup
/tmp/curl.sh is a bourne shell script that converts spaces to '+'
for the first argument passed to it:
#!/bin/sh
ARGV1=`echo "$1" | sed -e 's/ /+/g'`
/usr/bin/curl "${ARGV1}"
exit $?
Hope this helps.
See ya...
d.c.
----
P.S. For everyone that's been waiting for my modifications to support
retrieval of DLR's using the UUID...I'm still trying to get them
released from Upper Management... (for the past 5 months!!!)