Created
June 8, 2016 02:06
-
-
Save baslie/562da42d7815a2f0b0541a1d54967072 to your computer and use it in GitHub Desktop.
SMS: Send SMS via PHP & Bytehand.com
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Заголовок e-mail | |
switch ($_POST['subject']) { | |
case 'zvonok': | |
$subject = 'Обратный звонок'; | |
break; | |
case 'budjet': | |
$subject = 'Просчёт бюджета'; | |
break; | |
default: | |
$subject = 'Заявка с сайта'; | |
} | |
// Текст для e-mail | |
$text_for_email = "Имя: {$_POST['name']}\nТелефон: {$_POST['phone']}\nЧто рекламируем: {$_POST['what']}\nIP-адрес: {$_SERVER['REMOTE_ADDR']}\n"; | |
// Текст для СМС | |
$text_for_sms = "Имя: {$_POST['name']}, тел.: {$_POST['phone']}, реклама: {$_POST['what']}"; | |
// Отправляем письмо... | |
mail("example@mail.ru", "{$subject}", $text_for_email); | |
// Транслитерация смс-ок | |
function simplesms_translit($str) { | |
$translit = array( | |
"А"=>"A","Б"=>"B","В"=>"V","Г"=>"G", | |
"Д"=>"D","Е"=>"E","Ж"=>"J","З"=>"Z","И"=>"I", | |
"Й"=>"Y","К"=>"K","Л"=>"L","М"=>"M","Н"=>"N", | |
"О"=>"O","П"=>"P","Р"=>"R","С"=>"S","Т"=>"T", | |
"У"=>"U","Ф"=>"F","Х"=>"H","Ц"=>"TS","Ч"=>"CH", | |
"Ш"=>"SH","Щ"=>"SCH","Ъ"=>"","Ы"=>"YI","Ь"=>"", | |
"Э"=>"E","Ю"=>"YU","Я"=>"YA","а"=>"a","б"=>"b", | |
"в"=>"v","г"=>"g","д"=>"d","е"=>"e","ж"=>"j", | |
"з"=>"z","и"=>"i","й"=>"y","к"=>"k","л"=>"l", | |
"м"=>"m","н"=>"n","о"=>"o","п"=>"p","р"=>"r", | |
"с"=>"s","т"=>"t","у"=>"u","ф"=>"f","х"=>"h", | |
"ц"=>"ts","ч"=>"ch","ш"=>"sh","щ"=>"sch","ъ"=>"y", | |
"ы"=>"yi","ь"=>"","э"=>"e","ю"=>"yu","я"=>"ya" | |
); | |
return strtr($str,$translit); | |
} | |
// Функция отправки смс-ок | |
function simplesms_send($to, $text) { | |
$bytehandId = 12345; | |
$bytehandKey = '12345'; | |
$bytehandFrom = 'SMS-info'; | |
$query = 'http://bytehand.com:3800/send?id='.$bytehandId.'&key='.$bytehandKey.'&to='.urlencode($to).'&from='.urlencode($bytehandFrom).'&text='.urlencode(simplesms_translit($text)); | |
$result = @file_get_contents($query); | |
return $result; | |
if ($result === false) | |
return false; | |
else | |
return true; | |
} | |
// Отправляем смс-ку... | |
simplesms_send('+7123456789', $text_for_sms); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment