telegramBot::sendPhoto PHP Method

sendPhoto() public method

Send Photos.
public sendPhoto ( integer $chat_id, string $photo, string $caption = null, integer $reply_to_message_id = null, KeyboardMarkup $reply_markup = null ) : Array
$chat_id integer
$photo string
$caption string
$reply_to_message_id integer
$reply_markup KeyboardMarkup
return Array
    public function sendPhoto($chat_id, $photo, $caption = null, $reply_to_message_id = null, $reply_markup = null)
    {
        $data = compact('chat_id', 'photo', 'caption', 'reply_to_message_id', 'reply_markup');
        if (!is_dir($photo) && filter_var($photo, FILTER_VALIDATE_URL) === FALSE) {
            return $this->sendRequest('sendPhoto', $data);
        }
        return $this->uploadFile('sendPhoto', $data);
    }

Usage Example

コード例 #1
2
    while (true) {
        // Get lastUpdate ID
        $fileOfAuth = $dir . "/authchats.txt";
        if (is_file($fileOfAuth)) {
            $authDialogs = file($fileOfAuth);
        } else {
            file_put_contents($fileOfAuth, "");
            $authDialogs = array();
        }
        $photos = scandir($dir . "/new");
        foreach ($photos as $p => $photo) {
            if ($photo != ".." && $photo != ".") {
                echo $photo . "\r\n";
                foreach ($authDialogs as $i => $chatId) {
                    $tg->sendChatAction($chatId, 'upload_photo');
                    $tg->sendPhoto($chatId, $dir . "/new/" . $photo);
                }
                unlink($dir . "/new/" . $photo);
            }
        }
        sleep(2);
        if (is_file($dir . "/stopserver")) {
            unlink($dir . "/stopserver");
            fwrite($fLog, date("d.m.Y H:i:s") . " — Монитор остановлен по команде stopserver!\r\n");
            exit;
        }
    }
} else {
    fwrite($fLog, " Процесс уже запущен. Остановка!\r\n");
    echo "Одновременно может быть запущен только один процесс.";
    exit;
All Usage Examples Of telegramBot::sendPhoto