Products
Ozeki 10
SMS
Ozeki NG SMS Gateway
Message Server 6
SMS Wall
IP SMS Gateway
Android SMS
Excel SMS
Bulk Messenger
Cluster
Developer tools
Robots
Hardware
Installer
Technology
Company


Send SMS messages from PHP
/Send messages from a WWW pages/

Related pages:
PHP SMS with Mysql
PHP SMS with sendsms.php

The  Ozeki SMS Server  enables you to send and receive SMS messages from PHP scripts. The SMS Server and the PHP script can be located on two different computers. This means that more than one script can send messages at the same time with only one SMS Server (figure 1.).  


To send messages from PHP you need to use the file sendsms.php. This file is included in the SMS Server software package.  It provides functions to place the messages onto the SMS Servers queue for sending and to get the incoming messages. Take a look at the following example:

Sending SMS messages

<?php
include("sendsms.php");
$credits = sms_connect('192.168.0.1','9010','myAccount');

if ($credits>0) {
   sms_send('+36201234567','Hello World!');
}

sms_disconnect();
?>

Download sendsms.php...


/ example of sending SMS messages from PHP/

Receiving SMS messages

<?php

$OZEKISMS="/var/sms";

function sms_send($tel,$fromtel,$msg)
{
global $OZEKISMS;
$fn="send".time();
$handle = fopen ($OZEKISMS."/folders/outbox/".$fn.".lock", "w");
if (!$handle) {
# hiba
print "Write error. $OZEKISMS/folders/outbox/ is not writeable!\n";
return false;
} # end if
$handle = fopen ($OZEKISMS."/folders/outbox/".$fn, "w");
if (!$handle) {
# hiba
print "Write error. $OZEKISMS/folders/outbox/ is not writeable!\n";
return false;
} # end if
if (!fwrite($handle,$fromtel."\n")) {
print "Cannot write to file ($fn)";
return false;
}
if (!fwrite($handle,$tel."\n")) {
print "Cannot write to file ($fn)";
return false;
}
if (!fwrite($handle,$msg."\n")) {
print "Cannot write to file ($fn)";
return false;
}
fclose($handle);
unlink($OZEKISMS."/folders/outbox/".$fn.".lock");
return true;
} # end function

if(sms_send("+36305301903","Hello World!")) {
print "sms is under delivery.";
} else {
print "Error.";
}

?>

/ Alternate example of sending SMS messages from PHP using files/

Receiving SMS messages

<?
include("sendsms.php");
$credits = sms_connect('192.168.0.1','9010','myLogin');

echo "Receiving messages...<br>";
$inbox = sms_receive();
echo "$inbox";

sms_disconnect();
?>

/ example of receiving SMS messages from PHP/

 


Copyright © 2000- - Ozeki Ltd | info@ozeki.hu
Home > Products > SMS > Message Server 6 > Developers > PHP - SMS > Php
Legal | Privacy policy | Terms of use
Page: 142 | Login | 3.93.74.227