Android Sms网关的麻烦

时间:2015-11-19 09:23:06

标签: php android sms sms-gateway

所以我现在正在尝试为我工作的一个站点开发一些Sms服务。我正在使用名为Sms Gateway的Androip应用程序。出于测试目的,因为这是我第一次从网站上复制/粘贴代码。

以下是原文:

<?php

/*
This demo shows how to handle requests from SMS Gateway with full UTF-8 support and send reply SMS back
*/

//setup PHP UTF-8 stuff
setlocale(LC_CTYPE, 'en_US.UTF-8');
mb_internal_encoding("UTF-8");
mb_http_output('UTF-8');


//read parameters from HTTP Get URL
$phone = $_GET["phone"];
$smscenter = $_GET["smscenter"];
$text_utf8 = rawurldecode($_GET["text"]);

//if parameters are not present in HTTP url, they can be also present in HTTP header
$headers = getallheaders();
if (empty($phone)) {
        $phone = $headers["phone"];
}
if (empty($smscenter)) {
        $smscenter = $headers["smscenter"];
}
if (empty($text_utf8)) {
        $text_utf8 = rawurldecode($headers["text"]);
}



//create reply SMS
$reply_utf8 = mb_strtoupper($text_utf8); // mare reply message uppercased input message

//write reply to HTTP header
$reply_header = rawurlencode($reply_utf8);
header('Content-Type: text/html; charset=utf-8');
header("text: $reply_header"); //if you don't want reply sms, comment out this this line


// Debug outputs:
//echo "phone = $phone\n";
//echo "smscenter = $smscenter\n";
//echo "text_utf8 = $text_utf8\n";
//echo "reply_utf8 = $reply_utf8\n";
?>

这是我在服务器上运行的:

<?php
/*
This demo shows how to handle requests from SMS Gateway with full UTF-8 support and send reply SMS back
*/

//setup PHP UTF-8 stuff
mb_internal_encoding("UTF-8");
mb_http_output('UTF-8');


//read parameters from HTTP Get URL
$phone = $_GET["phone"];
$smscenter = $_GET["smscenter"];
$text_utf8 = rawurldecode($_GET["text"]);

//if parameters are not present in HTTP url, they can be also present in HTTP header
$headers = getallheaders();
if (empty($phone)) {
        $phone = $headers["phone"];
}
if (empty($smscenter)) {
        $smscenter = $headers["smscenter"];
}
if ($text_utf8 == "a") {
        sendResponse("Give me somthing so I know you are working!!!!!!!!");
}
else{
        sendResponse("Bad response");
}

function sendResponse($t){
    //write reply to HTTP header
    $reply_header = rawurlencode($t);
    header('Content-Type: text/html; charset=utf-8');
    header("text:".$t); //if you don't want reply sms, comment out this this line

}


// Debug outputs:
//echo "phone = $phone\n";
//echo "smscenter = $smscenter\n";
//echo "text_utf8 = $text_utf8\n";
//echo "reply_utf8 = $reply_utf8\n";
?>

当我查看日志时,我得到Http响应200.不知道该怎么做,任何帮助都非常受欢迎。

0 个答案:

没有答案