Products
INTEGRATED
STANDALONE
OTHER
Use this API to send text messages from PHP.
Simple HTTP request
Encrypted communication over SSL
Long SMS (up to 765 characters)
Delivery status via function return code
Email replies
function SendMessage($AccountID, $Email, $Password, $Recipient, $Message)
{
$Data['AccountID'] = $AccountID;
$Parameters['Email'] = $Email;
$Parameters['Password'] = $Password;
$Parameters['Recipient'] = Recipient;
$Parameters['Message'] = $Message;
Request($Parameters, 'http://sms1.redoxygen.net/sms.dll?Action=SendSMS');
}
function Request($Parameters, $URL)
{
$URL = preg_replace('@^http://@i', '', $URL);
$Host = substr($URL, 0, strpos($URL, '/'));
$URI = strstr($URL, '/');
$Body = '';
foreach($Parameters as $Key => $Value)
{
if (!empty($Body))
{
$Body .= '&';
}
$Body .= $Key . '=' . urlencode($Value);
}
$ContentLength = strlen($Body);
$Header = "POST $URI HTTP/1.1\n";
$Header .= "Host: $Host\n";
$Header .= "Content-Type: application/x-www-form-urlencoded\n";
$Header .= "Content-Length: $ContentLength\n\n";
$Header .= "$Body\n";
$Socket = fsockopen($Host, 80, $ErrorNumber, $ErrorMessage);
fputs($Socket, $Header);
while (!feof($Socket))
{
$Result[] = fgets($Socket, 4096);
}
fclose($Socket);
}