OK, this is the SCAR script i use for listening, will attach the PHP in a minute…
program New;
const
URL = 'http://localhost';
var
num, mess, LastMessage, SMS_Progress: string;
function SendSMS(URL, Number, Msg : string): Boolean;
var
Dbase : string;
Client : Integer;
begin
Client := InitializeHTTPClient(False, False);
ClearPostData(Client);
Wait(10);
AddPostVariable(Client, 'recipient', Number);
AddPostVariable(Client, 'message', Msg);
Dbase := PostHTTPPageEx(Client, URL+'/sendsms.php');
FreeHTTPClient(Client);
Result := true;
end;
function CheckForSMS(URL: string; var LastMessage:string): boolean;
var
buffer: string;
arr: TStringArray;
begin
buffer := GetPage(URL+'/MsgLog.txt');
Wait(10);
arr := Explode(#10, buffer);
if not (LastMessage = arr[high(arr)]) then
begin
Result := True;
LastMessage := arr[high(arr)];
end
else
Result := False;
buffer := '';
arr := ['','',''];
end;
procedure DealWithCommand(Msg:string);
var
TMess:TStringArray;
begin
TMess := Explode(' | ', Msg);
case lowercase(TMess[2]) of
'!progress':
begin
SendSMS(URL, TMess[1], SMS_Progress);
end;
end;
end;
begin
num := '********';
mess := 'This is the test message';
LastMessage := '';
ClearDebug;
SMS_Progress := '* Load Dropped = 32 *';
repeat
if CheckForSMS(URL, LastMessage) then
DealWithCommand(LastMessage);
until(false);
end.
Probably not the most efficient way to do it, but it works…
EDIT: Cant upload PHP… lol
[PHP]<?php
########################################################
# Login information for the SMS Gateway
########################################################
$ozeki_user = "";
$ozeki_password = "";
$ozeki_url = "
http://127.0.0.1:9501/api?";
########################################################
# Functions used to send the SMS message
########################################################
function httpRequest($url){
$pattern = "/http…([0-9a-zA-Z-.]*).([0-9]*).(.*)/";
preg_match($pattern,$url,$args);
$in = "";
$fp = fsockopen("$args[1]", $args[2], $errno, $errstr, 30);
if (!$fp) {
return("$errstr ($errno)");
} else {
$out = "GET /$args[3] HTTP/1.1\r\n";
$out .= "Host: $args[1]:$args[2]\r\n";
$out .= "User-agent: Ozeki PHP client\r\n";
$out .= "Accept: */*\r\n";
$out .= "Connection: Close\r\n\r\n";
fwrite($fp, $out);
while (!feof($fp)) {
$in.=fgets($fp, 128);
}
}
fclose($fp);
return($in);
}
function ozekiSend($phone, $msg, $debug=false){
global $ozeki_user,$ozeki_password,$ozeki_url;
$url = 'username='.$ozeki_user;
$url.= '&password='.$ozeki_password;
$url.= '&action=sendmessage';
$url.= '&messagetype=SMS:TEXT';
$url.= '&recipient='.urlencode($phone);
$url.= '&messagedata='.urlencode($msg);
$urltouse = $ozeki_url.$url;
if ($debug) { echo "Request: <br>$urltouse<br><br>"; }
//Open the URL to send the message
$response = httpRequest($urltouse);
if ($debug) {
echo "Response: <br><pre>".
str_replace(array("<",">"),array("<",">"),$response).
"</pre><br>"; }
return($response);
}
########################################################
# GET data from sendsms.html
########################################################
$phonenum = $_POST['recipient'];
$message = $_POST['message'];
$debug = false;
ozekiSend($phonenum,$message,$debug);
?>
[/PHP]
And for recieving
[PHP]<?php
$sender = $_GET['sender'];
$message = $_GET['msgdata'];
$id = $_GET['msgid'];
if ($sender!='') {
$fp = fopen("MsgLog.txt","a");
fputs($fp,"$id | $sender | $message\n");
fclose($fp);
} else {
echo "The PHP script is ready for accepting messages";
}
?>
[/PHP]