Основной сайт хуманэмулятор.рф | Демо | Купить | API | Wiki
Web / telegram
publish_to_channel
publish_to_channel($channel_id,$message,$schedule_date=""); - Публикация сообщения в каналФункция на вход принимает параметры:
После выполнения функции возвращаемое значение будет равно одному из двух :
Пример использования
<?php // Scenario: Demonstrates how to publish messages to Telegram channel $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>telegram->publish_to_channel</font>\n"; // get from: https://core.telegram.org/api $appID = "xxx"; $appHash = "xxx"; $myPhoneNumber = "+7xxx"; $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 4 echo ("\n4. Create channel: "); $channel_title = "Test Channel"; $channel_description = "Test channel description"; $is_megagroup = true; $channel_username = "test_channel_123"; $channel_id = WEB::$telegram->create_channel($channel_title, $channel_description, $is_megagroup, $channel_username); echo ("Channel ID: " . $channel_id); // Example 1 echo ("\n5. Publish message to channel: "); $message_text = "Test message to channel"; $publish_result = WEB::$telegram->publish_to_channel($channel_id, $message_text); echo ($publish_result); // Example 2 echo ("\n6. Publish media to channel: "); $media_message_text = "Message with media"; $file_path = "test_image.jpg"; // Replace with real file path $media_publish_result = WEB::$telegram->publish_media_to_channel($channel_id, $media_message_text, $file_path); echo ($media_publish_result); // Example 3 echo ("\n7. Create channel invite link: "); $expire_limit = 0; $usage_limit = 0; $invite_link = WEB::$telegram->create_channel_invite_link($channel_id, $expire_limit, $usage_limit); echo ("Invite link: " . $invite_link); // Example 4 echo ("\n8. Get channel subscribers: "); $subscriber_limit = 50; $subscribers = WEB::$telegram->get_channel_subscribers($channel_id, $subscriber_limit); if ($subscribers) { echo ("Number of subscribers: " . count($subscribers)); } else { echo ("Error getting subscribers"); } // step 9 echo ("\n9. Disconnect: "); echo (WEB::$telegram->disconnect()); // end echo "\n"; // Quit WINDOW::$app->quit();
=============================================
Telegram Объекты DOM System Vision Web Window
=============================================
если что-то непонятно или необходимо узнать или считаете что надо добавить по работе этой функции, пишите в комментарии или на наш форум
.