1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
| <?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";
?> |
Partager