发送GET给第三方
问题描述:
我试图设置一个SMS系统并使用aq.com发送文本(SMS)消息。发送GET给第三方
这工作正常,在浏览器中: http://gw1.aql.com/sms/postmsg.php?to_num=447943417499&message=HELLO&flash=0&originator=Me&username= &密码= ***
我得到了它的使用简单的header()函数在PHP工作的晚上。我现在无法使用header,ob_start/flush,fsock等工具。
什么是在这种情况下发送GET请求的最佳和可靠的方法。我能举一个基本的例子吗?
由于提前,:-)
页面经由SMS提供在文本消息中接收到这样的调试请求[编辑]是相当困难,特别是在共享主机上!!
答
首先有梨类此服务here
而且,这里是另一种实现方式:
function dosmsend($number, $message, $flash = "") {
// your aql username and password
$username = "yourusername";
$password = "yourpassword";
$weburl = "http://gw1.aql.com/sms/postmsg.php";
// encodes your message for sending on the web
$message = urlencode($message);
// the request string
$smsurl = "$weburl?username=$username&password=$password&to_num=$number&message=$message";
// if $flash is set to 1, it will add the flash request onto the query
if ($flash == "1")
$smsurl .= "&flash=1";
// connects to server to send message
if ($content_array = file($smsurl)) {
$content = implode("", $content_array);
// check for response
if (eregi("AQSMS-AUTHERROR", $content))
echo "There was an authenication error";
elseif (eregi("AQSMS-NOMSG", $content))
echo "There was no message or mobile number";
elseif (eregi("AQSMS-OK", $content))
echo "The Message was queued succcessfully";
elseif (eregi("AQSMS-NOCREDIT", $content))
echo "Your account has no credit";
}
else
echo "There was an error connecting to the server";
}
dosmsend("09978123456", "this is a test message");
//or
//dosmsend("09978123456","this is a test flash message oo!","1");
+0
我在网站上搜索了一个PHP示例,但只找到了C#示例。考虑到技术涉及他们的网站并不好,信息明智。该功能的作品,非常感谢你:-) –
答
对于大多数业务场景,处理第三方应保持到了一个极限,你希望尽可能多地控制自己的操作,除非涉及联盟营销业务以及通过这些程序致富的概念。
curl - http://php.net/manual/en/book.curl.php。它看起来可能会让人感到困惑,但在阅读了几个示例之后,您应该可以轻松地做出自己想做的事情。 – martincarlin87