public function sendPhotoAdmin($chatid, $fileid, $caption, $buttons = NULL) { $postdata…
- User
public function sendPhotoAdmin(file_id, buttons = NULL) { chat_id, 'photo' => caption, ]; // Если переданы кнопки, добавляем их к сообщению if (!is_null(buttons) && is_array(buttons)) { this->buildInlineKeyBoard($buttons); }
$ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'https://api.telegram.org/bot' . TELEGRAM_TOKEN . '/sendPhoto'); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data); curl_exec($ch); curl_close($ch); }мне нужно написать рассылку всем пользователям с фото и текстом к ней
- Assistant
Для отправки рассылки всем пользователям с фото и текстом вы можете использовать следующий код:
public function sendPhotoToAllUsers($file_id, $caption, $buttons = NULL) { // Получаем список всех пользователей $users = $this->getAllUsers(); // Отправляем фото и текст каждому пользователю foreach ($users as $user) { $chat_id = $user['chat_id']; $this->sendPhotoAdmin($chat_id, $file_id, $caption, $buttons); } } public function sendPhotoAdmin($chat_id, $file_id, $caption, $buttons = NULL) { $post_data = [ 'chat_id' => $chat_id, 'photo' => $file_id, 'caption' => $caption, ]; // Если переданы кнопки, добавляем их к сообщению if (!is_null($buttons) && is_array($buttons)) { $post_data['reply_markup'] = $this->buildInlineKeyBoard($buttons); } $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'https://api.telegram.org/bot' . TELEGRAM_TOKEN . '/sendPhoto'); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data); curl_exec($ch); curl_close($ch); }Вызовите функцию
sendPhotoToAllUsersи передайте ейfile_id(идентификатор файла фото),caption(текст к фото) и, если нужно, массивbuttons(массив с кнопками). Этот код пройдет по списку всех пользователей и отправит фото и текст каждому пользователю.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.