i want to create an app with telegram api and codeigniter. when i try to send image or others file, i get some error like this :
Message: file_get_contents(''): failed to open stream: HTTP request failed! HTTP/1.1 400 Bad Request
my controller is like this :
public function index()
{
this->tele = new telegramBot('token');
$path= base_url().'assets/maldini.png';
$info = $this->tele->sendPhoto('chati_id',$path);
print_r($info);
$this->load->view('tes');
}
}
how to solve this? thanks in advance :)
if you use this lib https://github.com/TelegramBot/Api, it's working code:
$chat_id = <chat_id>;
$token = <token>;
$bot = new \TelegramBot\Api\BotApi($token);
try {
$bot->sendPhoto($chat_id, <file_id>, 'caption');
//or if you file is local
//$bot->sendPhoto($chat_id, new \CurlFile(<local_file.jpg>), 'caption');
} catch (\TelegramBot\Api\Exception $e) {
$e->getMessage();
}
if not, this is simple GET method:
https://api.telegram.org/bot<token>/sendPhoto?chat_id=<chat_id>&photo=<file_id>
more info Telegram Bot API