Основной сайт хуманэмулятор.рф | Демо | Купить | API | Wiki
Web / telegram
find_chat_messages
find_chat_messages($chat_id,$text,$begin_date="",$end_date="",$offset_id=0); - Получить сообщения из чата по фильтруФункция на вход принимает параметры:
После выполнения функции возвращаемое значение будет равно одному из двух :
Пример использования
<?php // Scenario: Demonstrates how to find messages in a Telegram chat $xhe_host = getenv("RPABOT_HOST_URL"); if (!isset($path)) { // Path to the init.php file for connecting to the XHE API $path = "../../../Templates/init.php"; // Including init.php grants access to all classes and functionality for working with the XHE API require($path); } // beginning echo "\n<font color=blue>submitter->" . basename(__FILE__) . "</font>\n"; // get from: https://core.telegram.org/api $appID = "xxx"; $appHash = "xxx"; $myPhoneNumber = "+7xxx"; $contactPhoneNumber = "xxxxxx"; $password = "xxx!"; // step 1 echo ("1. Connect to telegram: "); echo (WEB::$telegram->connect($appID, $appHash)); // step 2 echo ("\n2. Request authorization: "); $res = WEB::$telegram->request_authorization($myPhoneNumber); echo ($res); if ($res != "connected") { // verification code input if ($res == "verification_code") { $auth_code = WINDOW::$app->get_dlg_input_string("dlg_1", "Enter authorization code from SMS or chat:"); // step 3 echo ("\n3. Authorize: "); $res = WEB::$telegram->authorization($myPhoneNumber, $res, $auth_code); echo ($res); } // password input if ($res == "password") { $auth_code = WINDOW::$app->get_dlg_input_string("dlg_1", "Enter password:"); // step 3 echo ("\n3. Authorize: "); $res = WEB::$telegram->authorization($myPhoneNumber, $res, $password); echo ($res); } if ($res != "ok") { echo ("\n4. Authorization failed: "); WINDOW::$app->quit(); } } // step 5 echo ("\n5. Get channels: "); $chanels = WEB::$telegram->get_chats("chanel"); echo (count($chanels)); // step 6 $id = $chanels[13]->id; $title = $chanels[13]->title; $searchText = "method"; // Example 1 echo ("\n6. Find messages containing specified text in channel $title: "); $messages = WEB::$telegram->find_chat_messages($id, $searchText); echo (count($messages)); SYSTEM::$textfile->write_file("d:/messages.res", json_encode($messages)); WINDOW::$app->shell_execute("open", "d:/messages.res"); // step 7 echo ("\n7. Disconnect: "); echo (WEB::$telegram->disconnect()); // end echo "\n"; // Quit WINDOW::$app->quit();
=============================================
Telegram Объекты DOM System Vision Web Window
=============================================
если что-то непонятно или необходимо узнать или считаете что надо добавить по работе этой функции, пишите в комментарии или на наш форум
.