简体   繁体   中英

How to create handy post message in telegram via bot on php

I want to create handy message like in this channel

All I've done is just here code sample

    $bot = new \TelegramBot\Api\Client('xxx:yyy');
    $bot->sendMessage("@dtsautocom", "<a href='https://dts-auto.com/{$passanger_car->main_photo}'>{$passanger_car->name}</a> \n{$passanger_car->year} год, {$passanger_car->price} $, пробег - {$passanger_car->mileage} км \nТелефон продавца: {$passanger_car->phone}", 'HTML');
$bot->run();

I wrapped image link to a tag and I get image, but this is not good solution and I've got this . I want to create like in the first link above. How did they do this? Can anyone give me please code sample of how to do it in right way? Thanks.

They used sendPhoto method with parse_mode set to HTML and formatted photo caption.

For your API library it should be:

  $bot->sendPhoto("@dtsautocom", "https://dts-auto.com/{$passanger_car->main_photo}", "{$passanger_car->name}\n{$passanger_car->year} год, {$passanger_car->price} $, пробег - {$passanger_car->mileage} км \nТелефон продавца: {$passanger_car->phone}", null, null, false, 'HTML');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM