Download the PHP package jaykee1/api without Composer

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

Introduction

Download Version API Version Stars

The API is an HTTP-based interface created for developers keen on building bots for Telegram. To learn how to create and set up a bot, please consult Telegram Introduction to Bots and Bot FAQ.

Requirements

  1. PHP 5.5+
  2. Composer - Dependency Manager for PHP
  3. yiisoft/yii2 - Yii PHP Framework Version 2
  4. Bot Token - Telegram Bot API Access Token

Installation

Install this package through Composer. Edit your project's composer.json file to require "jaykee1/api": "*" Or run this command in your command line:

Usage

The most common way of using this library is to create a new object from the API class, which allows you to access all of the authorized Telegram methods. By using the API class, events can also be used for you, which in the end of this article has been taught how to use it.

Request

As we said, this library is an HTTP-based interface, and all requests are sent using the POST method. To create a simple request, you must create a new object from the Request class and send the input parameters such as the method name.

You do not need to create your own requests in this way, you can use the same object you used to create the API class before. We've prepared for you all the methods in the documentation of the Telegram.

At the end and after sending your desired parameters, your request object is ready to be sent to the Telegram.

Response

After sending any request, you will receive a response, that is a Response object type. To send the request you created in the previous step, you must use the send() method and save the response in a variable.

According to the Telegram documentation about sending the message, after sending a message, you will receive a response like the Message object. In the response object you can use the has<Field>() method to verify a field and use get<Field>() to get the value of a field.

NOTE

Making any request that directly uses the Request object will send us an array response, not an object.

Methods

We will support all the methods already in the Telegram documentation. You can access all of them through src\methods and edit them if you wish. All methods in the API are case-insensitive. We only support POST HTTP method and we will use multipart/form-data for passing files to Telegram server.

Sending files

By file_id

If the file is already stored somewhere on the Telegram servers, you don't need to reupload it: each file object has a file_id field, simply pass this file_id as a parameter instead of uploading. There are no limits for files sent this way.

NOTE

file_id is unique for each individual bot and can't be transferred from one bot to another.

By URL

Provide Telegram with an HTTP URL for the file to be sent. Telegram will download and send the file. 5 MB max size for photos and 20 MB max for other types of content.

By InputFile

This object represents the contents of a file to be uploaded. Must be posted using multipart/form-data in the usual way that files are uploaded via the browser.

Keyboards

Traditional chat bots can of course be taught to understand human language. But sometimes you want some more formal input from the user — and this is where custom keyboards can become extremely useful.

Reply Keyboards

Whenever your bot sends a message, it can pass along a special keyboard with predefined reply options (see ReplyKeyboardMarkup). Telegram apps that receive the message will display your keyboard to the user. Tapping any of the buttons will immediately send the respective command. This way you can drastically simplify user interaction with your bot. Telegram currently support text and emoji for your buttons.

Here are some custom keyboard examples:

Inline Keyboards

There are times when you'd prefer to do things without sending any messages to the chat. For example, when your user is changing settings or flipping through search results. In such cases you can use Inline Keyboards that are integrated directly into the messages they belong to.

Unlike with custom reply keyboards, pressing buttons on inline keyboards doesn't result in messages sent to the chat. Instead, inline keyboards support buttons that work behind the scenes: callback buttons, URL buttons and switch to inline buttons.

When callback buttons are used, your bot can update its existing messages (or just their keyboards) so that the chat remains tidy.

Inline Mode

The following methods and objects allow your bot to work in inline mode. Please see Telegram Introduction to Inline bots for more details. To enable this option, send the /setinline command to @BotFather and provide the placeholder text that the user will see in the input field after typing your bot’s name.

Results

InlineQueryResult object represents one result of an inline query. Telegram clients currently support results of the following 20 types and you can find them through src\inline and edit it.

Answer to Query

Use answerInlineQuery method to send answers to an inline query. On success, True is returned.

No more than 50 results per query are allowed.

Helpers

Actions

Chat Actions let you broadcast a type of action depending on what the user is about to receive. The status is set for 5 seconds or less (when a message arrives from your bot, Telegram clients clear its typing status).

Formatting

The Bot API supports basic formatting for messages. You can use bold and italic text, as well as inline links and pre-formatted code in your bots' messages. Telegram clients will render them accordingly. You can use either markdown-style or HTML-style formatting.

NOTE

Telegram clients will display an alert to the user before opening an inline link (‘Open this link?’ together with the full URL).

Events

For developers who want to make better and more effective, we also include events in this library so that we can have full access to all requests and responses received and errors.

API object has four Events:

Disclaimer

This project and its author is neither associated or affiliated with Telegram in any way.

License

This project is released under the MIT License.


All versions of api with dependencies

PHP Build Version
Package Version
Requires yiisoft/yii2 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 jaykee1/api contains the following files

Loading the files please wait ....