All, I have an SMS gateway application running on my server that passes incoming SMS messages to a php script. That script writes the data to a text file. Certain aspects of the message can be extracted as variables - for example: Message content: $msgdata Sender: $originator Time: $receivedtime etc... Using the script below I can easily write the message to a text file but it will write the data of every SMS that comes in. I only want to write to a text file if the $originator variable is a certain telephone number (e.g 07123456321)
$date = date("d.m.Y H:i:s");
$msgdata = $_REQUEST["msgdata"];
$myFile3 = "test.txt";
$fh = fopen($myFile3, 'a') or die("can't open file");
$stringData3 = "$date - $msgdata\n";
fwrite($fh, $stringData3);
fclose($fh);
Your assistance is bery much appreciated. Many thanks in advance.
Since you can not do print_r for incoming messages you can frite $msgdata = $_REQUEST["msgdata"]; to your txt file. Then all you have to do is to open txt file and take a look at $originator key and then said:
if($msgdata->originator_key == '07123456321'){
//your function for writing to file here
}
If I understood correctly the question.