【问题标题】:Clickatell - redirect after the sms sentClickatell - 发送短信后重定向
【发布时间】:2015-07-11 12:33:00
【问题描述】:

我想在表单提交后集成 ang 短信通知,在发送短信后我想将其重定向到我的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 页面上。

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

【问题讨论】:

    标签: php sms clickatell


    【解决方案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的链接。

    【讨论】:

    • 您应该从 $url 变量中删除“位置:”
    • 我试过了,它发送 ng 消息但它重定向失败
    猜你喜欢
    • 2013-01-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-02-18
    • 1970-01-01
    相关资源
    最近更新 更多