ADD class SMS + notification on pulishing new article

This commit is contained in:
Krivchikov Dmitry 2015-12-11 15:12:53 +03:00
parent 116705395a
commit 69647288cd
3 changed files with 27 additions and 13 deletions

25
classes/SMS.php Normal file
View File

@ -0,0 +1,25 @@
<?php
class SMS
{
static public function send($text, $to = FALSE)
{
if (!App::getConfig('disableSMS')) {
$to = $to ? $to : '79046106141, 79046106144';
$ch = curl_init("http://sms.ru/sms/send");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_POSTFIELDS, array(
"api_id" => "2c2af6a7-a935-0e84-5952-599f5cd61905",
"to" => $to,
"text" => $text,
"from" => "WIKIPOINTS",
));
curl_exec($ch);
curl_close($ch);
}
}
}

View File

@ -142,6 +142,7 @@ class ArticleController extends Controller
$article->pubDate = time();
}
$article->status = 'published';
SMS::send('Статья: ' . $title . ' :: ' . App::$user->nick);
}
$article->title = $title ? $title : 'Без названия';

View File

@ -308,19 +308,7 @@ class JsonController extends Controller
die('Error 500 - Internal Server Error');
}
if (!App::getConfig('disableSMS')) {
$ch = curl_init("http://sms.ru/sms/send");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_POSTFIELDS, array(
"api_id" => "2c2af6a7-a935-0e84-5952-599f5cd61905",
"to" => "79046106141, 79046106144",
"text" => "#" . $point->id . ": " . $point->name . ' :: ' . App::$user->nick,
"from" => "WIKIPOINTS",
));
curl_exec($ch);
curl_close($ch);
}
SMS::send('#' . $point->id . ' ' . $point->name . ' :: ' . App::$user->nick);
}
self::renderPartial('json.php', array(