2015-07-11 71 views
2

我想提交表单后整合昂短信通知和短信发送后,我想将它重定向到我thankyou.html网页,这是我的代码:的Clickate - 改后的短信发送

<?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发送短信,我希望如果消息是成功的,我希望它在显示“Thank You”的.html页面上重定向。

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

回答

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

+1

你应该从$ url变量中删除“location:” –

+0

@ChrisBrand谢谢你,男人。赞赏。 –

+0

我试了一下,它发送ng消息,但它重定向失败 –