Forums

SMS Gateway API

Richard11 07 Feb, 2009
I would like to know where I need to put the api code in, to send an sms after a form is submitted. The contact number is unique to each form so there's no issue with dealing with tables or code in the form - I just want to send an sms to clients to ensure they respond appropriately to the form submission.

Thank you.
GreyHead 07 Feb, 2009
Hi Richard11,

You can add php+html in the OnSubmit boxes - OnSubmit After is probably the best for this.

Bob
Richard11 09 Feb, 2009
Hi Bob,

Thank you for your response, I'm afraid I have to apologise as I'm missing something here, I'm not sure what code I need to put in before the url address.

As you suggested I put the url address in on the OnSubmit boxes - OnSubmit After, but after the form is completed it simply shows the url address, doesn't execute the address which will send a message to

http://api.clickatell.com/http/sendmsg?user=xxxx&password=xxxxxx&api_id=xxxxxx&to=xxxxxxx%20&text=Please+check+your+mail.

If possible I previously put the thank you message in the OnSubmit Box - is it possible to have the api above hidden and a thank you message shown in html.

Thank you.

Richard11
Richard11 09 Feb, 2009
This worked - thank you
<?
$user = "user";
$password = "password";
$api_id = "xxxx";
$baseurl ="http://api.clickatell.com";
$text = urlencode("This is an example message");
$to = "0123456789";
// auth call
$url = "$baseurl/http/auth?user=$user&password=$password&api_id=$api_id";
// do auth call
$ret = file($url);
// split our response. return string is on first line of the data returned
$sess = split(":",$ret[0]);
if ($sess[0] == "OK") {
  $sess_id = trim($sess[1]); // remove any whitespace
  $url = "$baseurl/http/sendmsg?session_id=$sess_id&to=$to&text=$text";
  // do sendmsg call
  $ret = file($url);
  $send = split(":",$ret[0]);
  if ($send[0] == "ID") {
    echo "success message ID: ". $send[1];
  } else {
    echo "send message failed";
  }
} else {
  echo "Authentication failure: ". $ret[0];
  exit();
}
?>
yusufc 01 Jun, 2009
Thank for this code. I used it on my project.
1. Can I save response message to ChronoForms database ?
2. Can I use form elements in OnSubmit code ?
I'm using " $text = urlencode({text_10}); ".
But doesn't work.
yusufc 01 Jun, 2009
I found solution for question 2.
$text = $_POST['text_10'];
Thank you.

Can I save response message to ChronoForms database ?
This topic is locked and no more replies can be posted.