Download the PHP package idct/php-telegram-sender without Composer

On this page you can find all versions of the php package idct/php-telegram-sender. 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 php-telegram-sender

PHP Telegram Sender

Simple PHP library which simplifies the task of sending bot messages using Telegram IM.

Tests status Coverage Status GitHub tag (latest SemVer)

Installation

The best way to install the library in your project is by using Composer:

of course you can still manually include all the required files in your project using using statements yet Composer and autoloading is more than suggested.

Usage

Actions are handled via static methods as it is meant to be as simple as possible and at the moment there is no real benfit from instances of the main class.

To use it first add somewhere the use statement:

Then you have few methods available:

where 123123123 is bot's id.

Returns true or false depending on the fact if bot id is valid.

where 123123123 is bot's id.

Returns an instance of BotInfo.

Messages support HTML and Markdown depending on the $parseMode arguemnt's value.

$channel must be an instance of PublicChannel or PrivateChannel.

Example:

Values for the Bot and Channel constructors can be obtained from the Telegram app: check descriptions below.

Method returns an array of elements listed here: https://core.telegram.org/bots/api#message

TODO: Message entity in the library.

How to create a new bot?

  1. Contact BotFather user on Telegram

BotFather

  1. Type /newbot to the BotFather and answer all the asked questions.

New bot

  1. The part which looks like __635092640:AAGfG72lFg0L_Uf8Cfhb5wBi4UFTm7R2lDY__ are your bot's id and key. The part before : is the id and the part after is the key. So for the example above it would be:

id: 635092640 key: AAGfG72lFg0L_Uf8Cfhb5wBi4UFTm7R2lDY

so you would create an instance of the bot as follows:

Where to get the channel's id from?

  1. Create a channel using your Telegram client (New channel option in the hamburger menu on the left usually).

  2. Add your bot as the admin of the channel.

  3. Open https://web.telegram.org/ and sign in using your account.

  4. Click on the desired channel. The url in your browser will change.

  5. If the url changes to: https://web.telegram.org/#/im?p=c1282543751_17534450962567305630 then 1282543751 is your channel's id. So basically the part between c and _ after ? (in the query string).

  6. Use it to create PrivateChannel or PublicChannel instance depending on the visibility of your channel.

...I know it is quite complicated, but at the moment Telegram's API does not expose any method to get bot's channels.

Contribution

In order to contribute open a Pull Request or an Issue. At the moment there are two major points where contribution is more than welcome: support for additional methods of Telegram's API and better unit tests. Handling of the responses: like creating an entity class for the response would be very useful too.


All versions of php-telegram-sender with dependencies

PHP Build Version
Package Version
Requires php Version ^7.1
ext-curl Version *
myclabs/php-enum Version ^1.7.2
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 idct/php-telegram-sender contains the following files

Loading the files please wait ....