It's a way to use the telegram's response as Object instead of Array
From your project directory, run
composer require shakibonline/moon-telegram
require_once 'vendor/autoload.php';
/**
* @var array $update
*/
$message = new \Shakibonline\Message($update);
echo $message->Text() . PHP_EOL;
echo $message->Chat()->ID() . PHP_EOL;
echo $message->Chat()->Type() . PHP_EOL;
Check The type
/**
* @var array $update
*/
$type = MoonTelegram::Type($update);
if ( $type === MoonTelegram::MESSAGE ) {
$message = new Message($update);
$chat = $message->Chat();
} elseif ( $type === MoonTelegram::CALLBACK_QUERY ) {
$callback = new CallbackQuery($update);
$chat = $callback->Message()->Chat();
}
See Examples
folder
You can contact me via Telegram (EN and FA) but if you have an issue please open one.
Your welcome to any pull requests.