ADD class SMS + notification on pulishing new article
This commit is contained in:
parent
116705395a
commit
69647288cd
|
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -142,6 +142,7 @@ class ArticleController extends Controller
|
||||||
$article->pubDate = time();
|
$article->pubDate = time();
|
||||||
}
|
}
|
||||||
$article->status = 'published';
|
$article->status = 'published';
|
||||||
|
SMS::send('Статья: ' . $title . ' :: ' . App::$user->nick);
|
||||||
}
|
}
|
||||||
|
|
||||||
$article->title = $title ? $title : 'Без названия';
|
$article->title = $title ? $title : 'Без названия';
|
||||||
|
|
|
||||||
|
|
@ -308,19 +308,7 @@ class JsonController extends Controller
|
||||||
die('Error 500 - Internal Server Error');
|
die('Error 500 - Internal Server Error');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!App::getConfig('disableSMS')) {
|
SMS::send('#' . $point->id . ' ' . $point->name . ' :: ' . App::$user->nick);
|
||||||
$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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
self::renderPartial('json.php', array(
|
self::renderPartial('json.php', array(
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue