This script allows you to send SMS (also long SMS), EMS, RTTTL-Ringtones, Logos (GIF, JPG, PNG) with automatic image resizing, EMS Pictures with copy protection and autosave feature, Nokia Operator Logos, Nokia Multipart messages and so on. Pictures and Ringtones can be HEX-included or specified to be downloaded from a HTTP-source. You can setup the 2-way service within minutes on TrueSenses.com. Requires NO additional libraries programs or databases.
/* ************************************************************************************ * 2-way mobile messaging script, (c) 2003 TrueSenses.com - http://www.truesenses.com * * -> This script allows you to operate a 2-way SMS service and send ringtones, logos * -> and much more directly from your site. * * -> This script does not need any other execution rights like executing sub- * -> programs and should therefore run on almost every server supporting PHP. * * -> For outgoing SMS you will need to have a TrueSenses.com account. * -> For incoming SMS you will need to activate the keyword service for as low as * -> CHF 5.- (Swiss Francs) per keyword and month including unlimited incoming SMS. * * You will need to configure $truesenses_account,$truesenses_password and * $truesenses_origin * * This script is pre-configured to act on incoming SMS messages sent by the * TrueSenses.com SMS-Gateway. It will compare the incoming keyword and send back * the requested content. * * If you ONLY want to use this script to send messages (without 2-way service), * simply modify the MAIN program code to discard the incoming parameters provided * by the gateway: $NUMBER (origin number, international format) and $MESSAGE * * The following message-modes are supported: * * - SMS * - EMS * - EMS Images * - NOKIA Ringtones * - NOKIA Logos * - NOKIA Multipart messages (Picture Message with text) * * * In order to install the 2-way SMS script follow these steps: * * * 1. Open an account on TrueSenses.com * 2. Configure this script with your Account/Password and upload it to your server * 3. Buy some outgoing SMS credits * 4. Go to Configuration / Keyword services and add a keyword * 4.1 Click on the keyword and activate PUSH to forward incoming SMS to this script * example: http://www.[yoursitename].com/truesenses_2way.php * method: select POST method - dont forget to click on "Activated" * 4.2 Activate the keyword by clicking "Activate keyword" * 5. Your service is now up and running * * Send the following SMS to +41-79 381 60 10 or the number given by TrueSenses.com * * yourkeyword SMS * -> You will receive a SMS back to your phone. * * yourkeyword SMSFLASH * -> You will receive a flashing class 0 SMS back to your phone. * * yourkeyword NOKIARINGTONE * -> You will receive a ringtone for your NOKIA phone, downloaded from HTTP-Source. * * yourkeyword NOKIARINGTONEHEX * -> You will receive a ringtone for your NOKIA phone, included as hex-encoded. * * yourkeyword NOKIALOGO * -> You will receive an operator logo for your NOKIA phone, downloaded from HTTP- * -> source. IMPORTANT: configure the mnc and mmc settings first according to the * -> destination provider. Otherwise the logo will not show up. * * yourkeyword NOKIAMULTIPART * -> You will receive a picture message with a text for your NOKIA phone, downloaded * -> from a HTTP-source. * * yourkeyword EMSLOGO * -> You will receive a picture message for your NON-Nokia phone like SonyEricsson * -> and all other vendors who support the EMS-standard on their phones. The image * -> is by default copy protected and cannot be sent to another phone. You can de- * -> activate this by setting protected = "NO". * ************************************************************************************ */
// // compose the XML-message ans transfer it to sendToHost function sendXML($destination, $origin, $middle) { global $truesenses_account; global $truesenses_password;
// Look if incoming message contains a space (keyword detected) // // Incoming message will contain the full message (no keyword required) if you // are hosting a dedicated access number on TrueSenses // $pos = strpos ($MESSAGE, " ");
if ($pos === false) { // no space in message detected, keyword is message $KEYWORD = "$MESSAGE"; $MSGONLY = "$MESSAGE"; } else { // space detected, extract keyword $KEYWORD = substr($MESSAGE, 0, $pos); $MSGONLY = substr($MESSAGE, ($pos + 1), (strlen($MESSAGE) - ($pos))); }
if ($debug == 1) { echo("Keyword::$KEYWORD:: Msgonly::$MSGONLY:: Fullmessage::$MESSAGE::<br>\n"); }
if (strcmp(strtoupper($MSGONLY), "SMS") == 0) {
// sends a normal SMS
$xmlmsg = "<SMS encoded=\"YES\">\n"; // add the following line if you want to send long-SMS (spawning over multiple SMS) // $xmlmsg .= "<long />\n"; $xmlmsg .= "<CONTENT>"; $xmlmsg .= urlencode("Your keyword was $KEYWORD and your message was $MSGONLY"); // hex-encode the content $xmlmsg .= "</CONTENT>\n"; $xmlmsg .= "</SMS>\n";
if (strcmp(strtoupper($MSGONLY), "SMSFLASH") == 0) {
// sends a flasing SMS
$xmlmsg = "<SMS encoded=\"YES\">\n"; $xmlmsg .= "<flashing />\n"; // set msgclass 0 flag // add the following line if you want to send long-SMS (spawning over multiple SMS) // $xmlmsg .= "<long />\n"; $xmlmsg .= "<CONTENT>"; $xmlmsg .= urlencode("Your keyword was $KEYWORD and your message was $MSGONLY"); // hex-encode the content $xmlmsg .= "</CONTENT>\n"; $xmlmsg .= "</SMS>\n";
if ($debug == 1) { echo("RESPONSE::$rcbuf::\n"); } } // NOKIARINGTONE
if (strcmp(strtoupper($MSGONLY), "NOKIARINGTONEHEX") == 0) {
// sends a nokiaringtone as hex include - input must be in RTTTL format //
// assemble XML message
$http_location = urlencode("KnightRider:d=4,o=5,b=125:16e,16p,16f,16e,16e,16p,16e,16e,16f,16e,16e,16e,16d#,16e,16e,16e,16e,16p,16f,16e,16e,16p,16f,16e,16f,16e,16e,16e,16d#,16e,16e,16e,16d,16p,16e,16d,16d,16p,16e,16d,16e,16d,16d,16d,16c,16d,16d,16d,16d,16p,16e,16d,16d,16p,16e,16d,16e,16d,16d,16d,16c,16d,16d,16d"); // free demo ringtone from the internet
if ($debug == 1) { echo("RESPONSE::$rcbuf::\n"); } } // NOKIALOGO
if (strcmp(strtoupper($MSGONLY), "NOKIAMULTIPART") == 0) {
// sends a nokiamultipart message (picturemessage) - input must be in GIF, JPG or PNG // // options: // - specify <CONTENT> tag if you want to send some text with your image
// assemble XML message
$http_type = "GIF"; $http_location = "http://www.simmcomm.ch/nokialogo.gif"; // location of the logo
if ($debug == 1) { echo("RESPONSE::$rcbuf::\n"); } } // NOKIAMULTIPART
if (strcmp(strtoupper($MSGONLY), "EMSLOGO") == 0) {
// sends a logo to NON-nokia, EMS-capable phones like SonyEricsson // // parameters: // autosave = YES/NO (automatically ask user to save image) // protected = YES/NO (disallow re-distribution of image) // width = x (width of image, do not provide parameter for autosizing) // height = y (height of image, do not provide parameter for autosizing)
// assemble XML message
$http_type = "GIF"; $http_location = "http://www.simmcomm.ch/nokialogo.gif"; // location of the logo
$xmlmsg = "<EMS>\n"; // no newline after <content> tag as it would convert to text-enter %0A in ems and would consume space $xmlmsg .= "<CONTENT><IMAGE source=\"HTTP\" type=\"$http_type\" autosave=\"YES\" protected=\"NO\">$http_location</IMAGE></CONTENT>\n"; $xmlmsg .= "</EMS>\n";
if ($debug == 1) { echo("RESPONSE::$rcbuf::\n"); } } // EMSLOGO
// send confirmation to TrueSenses.com that we have received the incoming sms
echo("OK<br>\n"); ?> </body> </html>
DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.