Configuring Notifications
Sending notifications
There are several ways to receive notifications in the Control panel:
- via email;
You must specify your email address.
- via SMS;
You need to purchase an SMS package to subscribe to SMS. You can replenish the balance on the “Contacts” page. Only Russian/Ukrainian phone numbers are allowed. This is due to the higher cost for SMS to phone numbers in other countries.
- via HTTP requests.
Receiving and processing HTTP requests
For GET requests:
- Create a .php file in the directory with the site.
- Select Monitoring — Notification center — Contacts in the Control panel.
- Add the absolute address of the file link as an HTTP contact, for example: http://test-http-get.ru/log.php. The Control panel will display a message with the expected response, which the log.php script should give.
- Add the following code to the script file:
?php
echo "5ca8ada39381ec79e881132b1fa3dac3"; // where 5ca8ada39381ec79e881132b1fa3dac3 is the code from the panel
?
- Click Confirm in the Control panel.
- Once the confirmation is complete, modify the log.php file and add a working script to it.
Script example
The specified script sends a message to Telegram messenger if a new entry appears in the monitoring message log:
- Create a log directory in the root of the site.
- Create a file named get.log to log GET requests.
- Add the log.php to the same directory with the following contents:
?php
$file_get = $_SERVER["DOCUMENT_ROOT"] . "/modules/log/get.log";
if (!empty($_GET)) {
$fw = fopen($file_get, "a");
fwrite($fw, "GET " . var_export($_GET, true));
fclose($fw);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,
"https://api.telegram.org/bot864190220:AAGY3To77NuySjaGmupS7PfEQy952V08QOA/sendMessage?chat_id=217490943&text='New entry in the monitoring file: http://test-http-get.ru/modules/log/get.log'");
$result=curl_exec($ch);
curl_close($ch);
}
?
To get a chat ID:
- Start a chat with the bot from your account.
- Get the list of updates for your bot:
https://api.telegram.org/bot<YourBOTToken>/getUpdates
- Copy the value of the chat_id parameter.
The script is configured as follows:
- Using the var_export function, the script records information about the GET request to get.log.
- Specify the key (token) of the Telegram bot instead of 864190220:AAGY3To77NuySjaGmupS7PfEQy952V08QOA.
- Specify the chat ID with the bot in the chat_id parameter.
- Specify the address of the link to the file instead of http://test-http-get.ru/get.log.