Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/249.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
无法使我的Php脚本与我的clickatell API一起工作_Php_Api_Sms_Clickatell - Fatal编程技术网

无法使我的Php脚本与我的clickatell API一起工作

无法使我的Php脚本与我的clickatell API一起工作,php,api,sms,clickatell,Php,Api,Sms,Clickatell,下面是我的代码。它应该在您将您的电话号码输入到字段表单后发送SMS消息,但它不发送消息 URL必须是?后面是代码中下面列出的变量。我尝试使用Php脚本发送短信,而不是将浏览器指向clickatell网站进行HTTP访问。如果这有意义的话 // The original link that worked using a simple META Refresh after form submit // http://api.clickatell.com/http/sendmsg?user=amdo

下面是我的代码。它应该在您将您的电话号码输入到字段表单后发送SMS消息,但它不发送消息

URL必须是?后面是代码中下面列出的变量。我尝试使用Php脚本发送短信,而不是将浏览器指向clickatell网站进行HTTP访问。如果这有意义的话

// The original link that worked using a simple META Refresh after form submit 
// http://api.clickatell.com/http/sendmsg?user=amdoch&password=OVUbMIXCZUeMIg&api_id=3536796&MO=1&from=19044383575&to=1". $phone . "&text=Dolphin%20Cruise%20Test%20Text

$user = "amdoch";
$password = "MYPASSWORDHERE";
$api_id = "MYAPIID";
$baseurl ="http://api.clickatell.com";
$text = urlencode("This is an example message");
$phone = $_POST['phone'];
$from = "19044383575";
$to = $phone;

// auth call
$url = "$baseurl/http/auth?user=$user&password=$password&api_id=$api_id";

// do auth call
$ret = file($url);

// explode our response. return string is on first line of the data returned
$sess = explode(":",$ret[0]);
if ($sess[0] == "OK") {

    $sess_id = trim($sess[1]); // remove any whitespace
    $url = "$baseurl/http/sendmsg?session_id=$sess_id&MO=1&from=$from&to=$to&text=$text";

    // do sendmsg call
    $ret = file($url);
    $send = explode(":",$ret[0]);

    if ($send[0] == "ID") {
        echo "successnmessage ID: ". $send[1];
    } else {
        echo "<META http-equiv=refresh content=0;URL=http://www.localsadvise.com>send message failed";
    }
} else {
    echo "Authentication failure: ". $ret[0];
}
//表单提交后使用简单元刷新工作的原始链接
// http://api.clickatell.com/http/sendmsg?user=amdoch&password=OVUbMIXCZUeMIg&api_id=3536796&MO=1&from=19044383575&to=1“$phone.”&text=Dolphin%20Cruise%20Test%20Text
$user=“amdoch”;
$password=“MYPASSWORDHERE”;
$api_id=“myapid”;
$baseurl=”http://api.clickatell.com";
$text=urlencode(“这是一条示例消息”);
$phone=$_POST['phone'];
$from=“19044383575”;
$to=$phone;
//授权呼叫
$url=“$baseurl/http/auth?user=$user&password=$password&api\u id=$api\u id”;
//进行身份验证呼叫
$ret=文件($url);
//引爆我们的反应。返回字符串位于返回数据的第一行
$sess=explode(“:”,$ret[0]);
如果($sess[0]==“确定”){
$sess_id=trim($sess[1]);//删除所有空白
$url=“$baseurl/http/sendmsg?会话_id=$sess_id&MO=1&from=$from&to=$to&text=$text=$text”;
//你打电话吗
$ret=文件($url);
$send=explode(“:”,$ret[0]);
如果($send[0]=“ID”){
echo“successnmessage ID:”.$send[1];
}否则{
回显“发送消息失败”;
}
}否则{
echo“身份验证失败:.$ret[0];
}
您正在使用的file()函数不会指向Clickatell网站(就像file\u get\u contents()或curl函数一样)

您可能会看到Clickatell系统的API响应,因为您的脚本中包含以下内容:

回显“成功消息ID:”$发送[1]


把那句话删掉……我试试看。你有使用clickatell的经验吗?我试图从他们那里得到支持,但运气不好。我在clickatell网站上找到了这个脚本。不,那不起作用。仍然无法发送消息。我想问题出在URL的某个地方。我正在使用一个带有clickatell的HTTP API。他们没有为开发人员提供任何形式的支持,这真是太糟糕了。只是为了让你知道我在努力实现什么。我想发送短信,然后让最终用户重定向回我的网站。如果可能的话,我真的不想要任何外部链接。因此,Php脚本。Clickatell告诉我使用HTTP回调函数,我对此一无所知。另外,我所读到的关于HTTP回调的所有内容都表明,这并不是我真正想要的。好的,您第一次描述的问题是关于重定向的,问题解决了吗?关于您的新问题:如果您的消息失败,请告诉我们服务器的响应是什么(可能将其记录到文件)…您可能还希望从示例中删除密码。