dongze8698 2015-11-19 09:23
浏览 37

Android Sms网关的麻烦

So I'm currently trying to develop some Sms service for one site on which I work. I'm using an Androip app called Sms Gateway. For the purposes of testing because it is my first time I just copy/paste the code from there website.

Here is the original:

<?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
";
//echo "smscenter = $smscenter
";
//echo "text_utf8 = $text_utf8
";
//echo "reply_utf8 = $reply_utf8
";
?>

And this is mine which runs on the server:

<?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
";
//echo "smscenter = $smscenter
";
//echo "text_utf8 = $text_utf8
";
//echo "reply_utf8 = $reply_utf8
";
?>

When I check the logs I get Http response 200. Don't know what to do, any help is more than welcome.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 孟德尔随机化结果不一致
    • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
    • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
    • ¥15 谁有desed数据集呀
    • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
    • ¥15 关于#hadoop#的问题
    • ¥15 (标签-Python|关键词-socket)
    • ¥15 keil里为什么main.c定义的函数在it.c调用不了
    • ¥50 切换TabTip键盘的输入法
    • ¥15 可否在不同线程中调用封装数据库操作的类