Download the PHP package bahramali/telegram-bot-php without Composer

On this page you can find all versions of the php package bahramali/telegram-bot-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package telegram-bot-php

Telegram Bot PHP

Telegram Bot PHP is a PHP Library for interaction with Telegram Bot API 5.4 (November 5, 2021).

Table

Requirements

Please read the Telegram API document at least once

or

or

Create composer.json file and add

and run

Note: If you don't have Composer you can download it HERE.

Usage

To use this library, you need to require the Composer Autoloader And create a new object from the bot class

Please read the Telegram API document at least once

Security

You can add a specific parameter to your webhook url so that only you know about that link.

Example:

Then check in your code the parameter that must be present

Be sure to check that the IP is the sender of the Telegram IP.

You can use the 'isTelegramIp' function of 'bot' class to check Telegram IP

Example:

Config

Configs

You can adjust the configuration and change it in each section

if you are using a local bot api server, Set up your server url

if you are using a local bot api server, Set up your server file url, for download file

Convert updates and response to objects for easier access

Also you can set the variable to false and receive updates and response as an array

If you don't want to use Webhook automatically, set this variable to false

If you don't want some methods to have some of their parameters automatically, set this variable to false

Its accuracy is not always guaranteed

If you want the program to continue after the error, set this variable to false

This is only for when the response code of the submitted request is not equal to 200

Logging

This library can log all their update , requests , responses and errors

Just set the function for the desired log

You can change any of the functions anywhere in the app

Get the information and you can use any method you want to record it

onLog

For updates , requests , responses and errors

At the end, the program is called and sends update and a list of all requests and responses and errors as input

Example

onLogUpdate

For update only

When the update is received, the function is called

Example

onLogRequestAndResponse

For requests and responses only

When a request is sent and the response code is 200

Example

onLogError

For errors only

When a request is sent and the response code is not 200

Example

Main Config

The main configuration is constant everywhere in the program And when a new configuration is created, the default value is the value set for the main configuration.

You can adjust the main configuration and change it in each section

Note: You can see the default values above

Use

It should only be used statically

Use Config

Just create an object of config class and change the values

Note: The default configuration values are the Main configuration values

Set

To use the created configuration, it can be set to the second parameter of the bot class

It can also be changed later if needed

Update

There are two ways to receive the update

There is no difference between camelCase and under_score to get the parameters

Webhook

If you are using a webhook you can get updates using the 'getUpdate' and 'getInput' functions

https://core.telegram.org/bots/api#setwebhook

Example

Get Updates

Returns an array of update object

https://core.telegram.org/bots/api#getupdates

Example:

Methods

To use the methods, all you have to do is type in the name of the method and pass an array of parameters listed in the Telegram api document.

Example:

You can also use static

Example:

Also to use different BOT_API_TOKEN

You can in the second parameter of each method, Enter a new BOT_API_TOKEN

Example:

Keyboards

InlineKeyboardMarkup

ReplyKeyboardMarkup

ReplyKeyboardRemove

ForceReply

Response

There is no difference between camelCase and under_score to get the parameters

Get Response

Result

Example:

Error:

Request:

Download File

download file by file_id

Helper

Helpers are auxiliary functions for receiving certain values or checking some items or doing certain tasks

Note: You can see the full list of functions in the Helpers Folder

There is no difference between camelCase and under_score to get the parameters

Example:

You can also create a new helper with the input update array

Of course, the bot builds the helper itself and there is no need to build a helper with its value, You can get the bot helper with 'getHelper'

Example:

Format

The Format class is a class to help create different text formats

https://core.telegram.org/bots/api#formatting-options

Mention

You can easily mention users

Styles

Example:

Example:

Exceptions

You can manage errors with try catch

BotException: Main exception class used for exception handling

BotLogException: exception class used for log

BotNotSupportException: exception class Thrown when Feature not support

Update Type

If you want to check the type of updates

You can use helpers

You can see the full list of 'updateTypeIs...' functions in the helper type class

Example:

Or

You can use the 'getUpdateType' helper to get the type of update and then check it using different types of updates

You can see the full list of update types in the update type class

Example:

Chat Action

You can use existing chat actions to send chat action

You can see the full list of chat actions in the chat action class

Example:

Examples

Troubleshooting

please report any bugs you find on the issues page.

About Us

This library can be used for easy interaction with Telegram Bot API

License

Telegram-Bot-PHP is licensed under the MIT License - see the LICENSE file for details


All versions of telegram-bot-php with dependencies

PHP Build Version
Package Version
Requires php Version >=7.4
ext-curl Version *
ext-json Version *
ext-mbstring Version *
ext-openssl Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package bahramali/telegram-bot-php contains the following files

Loading the files please wait ....