Upgrading To 2.0 from 1.x

📘

Refer Changelog

Check out the CHANGELOG for detailed info on what's changed.

There are some breaking and major changes in this new version. Follow the below instructions to apply the changes.

Upgrading Your Composer Dependency

To update the package in composer, fire the following command in your terminal:

$ composer require irazasyed/telegram-bot-sdk ^2.0

Updating method parameters

Due to rapid amount of changes Telegram have made to their method parameter names and order, this version now requires all main methods to be called with an array of parameters rather than individual parameters.

sendMessage()
forwardMessage()
sendPhoto()
sendAudio()
sendDocument()
sendSticker()
sendVideo()
sendVoice()
sendLocation()
sendChatAction()
getUserProfilePhotos()
getUpdates()
setWebhook()
getFile()
replyKeyboardMarkup()
replyKeyboardHide()
forceReply()

For example, in version 1.0 of the API the sendMessage() method would have been called as follows:

$response = $telegram->sendMessage('CHAT_ID', 'Hello World');

You must now pass an associative array to the method instead like so:

$response = $telegram->sendMessage([
    'chat_id' => 'CHAT_ID', 
    'text' => 'Hello World'
]);

All methods in the API are heavily documented, follow the official Telegram documentation and should provide easy guidance of required array key names, especially if you use an IDE.

That's all folks, Enjoy!

Always make sure to update the package in your project to latest version to apply all the bug-fixes, security updates, tweaks and other cool new features.