Clickatell - 发送短信后重定向

时间:2015-07-11 12:33:00

标签: php sms clickatell

我希望在提交表单后整合ang sms通知,并在发送短信后我想将其重定向到我的thankyou.html网页,这是我的代码:

<?php
if(isset($_POST['send'])){
$query="insert into table() values() ";
if(mysql_query($query)){
 header("location:http://api.clickatell.com/http/sendmsg?api_id=3549342&user=xxxx&password=xxxx&to=63926475xxxx&text=xxxx ");
}
}
?>
<form method=post >
Username: input type=text name=user >
Password: <input type=text name=pass >
Name: <input type=text name=name >
Mobile number: <input type=text name=mobile_no >
<input type=submit name=submit >
</form>

假设查询返回true,它将发送短信,使用clickatell api,我想要的是如果消息成功我希望它重定向到我的.html页面上显示&#34;谢谢你&#34;

我是这个api的新手,谢谢!

1 个答案:

答案 0 :(得分:1)

为什么不在这里使用file函数来检索api url的内容?

<?php
  $url = "http://api.clickatell.com/http/sendmsg?api_id=3549342&user=xxxx&password=xxxx&to=63926475xxxx&text=xxxx";

  $data = file($url);

  $dataArr = explode(":",$data[0]);

  if ($dataArr[0] == "OK") 
  {
    //do the redirection here
    header("location:your.html");
    exit;
  } 
  else 
  {
    echo "Failed: ".$dataArr[1]; //apparently $dataArr[0] contains 'ERR' and has no details regarding the error.
  }
?>

您可以通过

查看收到的全部内容
print_r($dataArr);

以下是developer guide的链接。

相关问题