inbound sms in php


The sms gateway as system like inbound and outbound sms in which out bound sms used to send sms to number through http ,we usually get service code in any language like php,python,asp provided by sms gateway api provider.But inbound is like to send msg from mobile to http system service is not provided,they will provide URL like example.com/response.php to receive parameter by get or post method so we receive http request write down in text file like in code below.Make sure give right permission to write on text file.

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 

<style type="text/css">
table.gridtable {
    font-family: verdana,arial,sans-serif;
    font-size:11px;
color:#333333;
    border-width: 1px;
    border-color: #666666;
    border-collapse: collapse;
}
table.gridtable th {
    border-width: 1px;
padding: 8px;
    border-style: solid;
    border-color: #666666;
    background-color: #ebf4fb;
}
table.gridtable td {
    border-width: 1px;
padding: 8px;
    border-style: solid;
    border-color: #666666;
    background-color: #ffffff;
}
</style>

</head>
<body>

<?php

if( $_POST!=0||$_POST!=null){
    $dcs=urldecode($_POST['dcs']);
    $msgid =urldecode($_POST['msgid']);
   $sender = urldecode($_POST['sender']);// do not need to change
    $receiver = urldecode($_POST['receiver']); // do not need to change
        $text = urldecode($_POST['text']); // do not need to change
//$array = $_['text'];
$filename = "messages.txt";
    if ($from == "") {

    } else {
        $f=fopen("$filename","a");
        fwrite($f,"$dcs;$msgid;$sender;$receiver;$text;\r\n");
        fclose($f);
    }

    
    if (file_exists($filename)) {
        echo "<b>Message</b>";
        echo "<table class='gridtable'>";
        echo "<th>#</th><th>dcs</th><th>msgid</th><th>sender</th><th>receiver</th><th>text</th>";
        
        $lines = file($filename);
        foreach($lines as $line_num => $line){
        
            $xl = explode(";", $line);
            $rnr++;
            //var_dump($xl); echo '</br>';
        echo "<tr><td>$rnr</td><td>$xl[0]</td><td>$xl[1]</td><td>$xl[2]</td><td>$xl[3]</td><td>$xl[4]</td></tr>";
        }
        
        echo "</table>";
    } else {
        echo "<b>none</b>";
    }

}else{
echo "<hr><a href=\"response.php\">sms</a>";
}
?>

</body>
</html>

Advertisements
About

myself pramodh kumar yet another php developer from India and have worked on oops,procedural,yii framework,codeigniter,wordpress,joomla,api and more.

Tagged with: , , , , ,
Posted in sms gateway

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow php tutorial on WordPress.com
categories
Calendar
September 2014
M T W T F S S
« Aug   Oct »
1234567
891011121314
15161718192021
22232425262728
2930  
Follow me on Twitter
Blog Stats
  • 73,741 hits
%d bloggers like this: