Skip to content

Commit 676206a

Browse files
authored
Merge pull request #112 from Yousha/master
Update README.md
2 parents dea42d1 + 7417561 commit 676206a

File tree

1 file changed

+78
-24
lines changed

1 file changed

+78
-24
lines changed

README.md

Lines changed: 78 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7,42 +7,72 @@
77
[![License](https://poser.pugx.org/eleirbag89/telegrambotphp/license)](https://packagist.org/packages/eleirbag89/telegrambotphp)
88
[![StyleCI](https://styleci.io/repos/38492095/shield?branch=master)](https://styleci.io/repos/38492095)
99

10-
> A very simple PHP [Telegram Bot API](https://core.telegram.org/bots).
11-
> Compliant with the August 23, 2017 Telegram Bot API update.
10+
A very simple PHP [Telegram Bot API](https://core.telegram.org/bots).
11+
Compliant with the August 23, 2017 Telegram Bot API update.
1212

1313
Requirements
1414
---------
1515

16-
* PHP5
17-
* Curl for PHP5 must be enabled.
16+
* PHP >= 5.3
17+
* Curl extension for PHP5 must be enabled.
1818
* Telegram API key, you can get one simply with [@BotFather](https://core.telegram.org/bots#botfather) with simple commands right after creating your bot.
1919

2020
For the WebHook:
21-
* An SSL certificate (Telegram API requires this). You can use [Cloudflare's Free Flexible SSL](https://www.cloudflare.com/ssl) which crypts the web traffic from end user to their proxies if you're using CloudFlare DNS.
21+
* An VALID SSL certificate (Telegram API requires this). You can use [Cloudflare's Free Flexible SSL](https://www.cloudflare.com/ssl) which crypts the web traffic from end user to their proxies if you're using CloudFlare DNS.
2222
Since the August 29 update you can use a self-signed ssl certificate.
2323

24-
For the GetUpdates:
24+
For the getUpdates(Long Polling):
2525
* Some way to execute the script in order to serve messages (for example cronjob)
2626

27+
Download
28+
---------
29+
30+
#### Using Composer
31+
32+
From your project directory, run:
33+
```
34+
composer require eleirbag89/telegrambotphp
35+
```
36+
or
37+
```
38+
php composer.phar require eleirbag89/telegrambotphp
39+
```
40+
Note: If you don't have Composer you can download it [HERE](https://getcomposer.org/download/).
41+
42+
#### Using release archives
43+
44+
https://github.com/Eleirbag89/TelegramBotPHP/releases
45+
46+
#### Using Git
47+
48+
From a project directory, run:
49+
```
50+
git clone https://github.com/Eleirbag89/TelegramBotPHP.git
51+
```
52+
2753
Installation
2854
---------
2955

56+
#### Via Composer's autoloader
3057

31-
* Copy Telegram.php into your server and include it in your new bot script
58+
After downloading by using Composer, you can include Composer's autoloader:
3259
```php
33-
include("Telegram.php");
34-
$telegram = new Telegram($bot_token);
60+
include (__DIR__ . '/vendor/autoload.php');
61+
62+
$telegram = new Telegram('YOUR TELEGRAM TOKEN HERE');
3563
```
3664

37-
* To enable error log file, also copy TelegramErrorLogger.php in the same directory of Telegram.php file
65+
#### Via TelegramBotPHP class
3866

39-
#### Using Composer
67+
Copy Telegram.php into your server and include it in your new bot script:
68+
```php
69+
include 'Telegram.php';
4070

41-
From your project directory, run
42-
```
43-
composer require eleirbag89/telegrambotphp
71+
$telegram = new Telegram('YOUR TELEGRAM TOKEN HERE');
4472
```
4573

74+
Note: To enable error log file, also copy TelegramErrorLogger.php in the same directory of Telegram.php file.
75+
4676
Configuration (WebHook)
4777
---------
4878

@@ -54,19 +84,21 @@ Examples
5484
---------
5585

5686
```php
57-
$telegram = new Telegram($bot_token);
87+
$telegram = new Telegram('YOUR TELEGRAM TOKEN HERE');
88+
5889
$chat_id = $telegram->ChatID();
59-
$content = array('chat_id' => $chat_id, 'text' => "Test");
90+
$content = array('chat_id' => $chat_id, 'text' => 'Test');
6091
$telegram->sendMessage($content);
6192
```
6293

6394
If you want to get some specific parameter from the Telegram response:
6495
```php
65-
$telegram = new Telegram($bot_token);
96+
$telegram = new Telegram('YOUR TELEGRAM TOKEN HERE');
97+
6698
$result = $telegram->getData();
67-
$text = $result["message"] ["text"];
68-
$chat_id = $result["message"] ["chat"]["id"];
69-
$content = array('chat_id' => $chat_id, 'text' => "Test");
99+
$text = $result['message'] ['text'];
100+
$chat_id = $result['message'] ['chat']['id'];
101+
$content = array('chat_id' => $chat_id, 'text' => 'Test');
70102
$telegram->sendMessage($content);
71103
```
72104

@@ -81,23 +113,26 @@ $telegram->sendPhoto($content);
81113
To download a file on the Telegram's servers
82114
```php
83115
$file = $telegram->getFile($file_id);
84-
$telegram->downloadFile($file["result"]["file_path"], "./my_downloaded_file_on_local_server.png");
116+
$telegram->downloadFile($file['result']['file_path'], './my_downloaded_file_on_local_server.png');
85117
```
86118

87119
See update.php or update cowsay.php for the complete example.
88120
If you wanna see the CowSay Bot in action [add it](https://telegram.me/cowmooobot).
89121

90-
If you want to use GetUpdates instead of the WebHook you need to call the the `serveUpdate` function inside a for cycle.
122+
If you want to use getUpdates instead of the WebHook you need to call the the `serveUpdate` function inside a for cycle.
91123
```php
124+
$telegram = new Telegram('YOUR TELEGRAM TOKEN HERE');
125+
92126
$req = $telegram->getUpdates();
127+
93128
for ($i = 0; $i < $telegram-> UpdateCount(); $i++) {
94129
// You NEED to call serveUpdate before accessing the values of message in Telegram Class
95130
$telegram->serveUpdate($i);
96131
$text = $telegram->Text();
97132
$chat_id = $telegram->ChatID();
98133

99-
if ($text == "/start") {
100-
$reply = "Working";
134+
if ($text == '/start') {
135+
$reply = 'Working';
101136
$content = array('chat_id' => $chat_id, 'text' => $reply);
102137
$telegram->sendMessage($content);
103138
}
@@ -113,6 +148,7 @@ For a complete and up-to-date functions documentation check http://eleirbag89.gi
113148

114149
Build keyboards
115150
------------
151+
116152
Telegram's bots can have two different kind of keyboards: Inline and Reply.
117153
The InlineKeyboard is linked to a particular message, while the ReplyKeyboard is linked to the whole chat.
118154
They are both an array of array of buttons, which rapresent the rows and columns.
@@ -187,6 +223,7 @@ Check [ForceReply](https://core.telegram.org/bots/api#forcereply) for more info.
187223

188224
List of Bots using the library
189225
------------
226+
190227
Let me know using this [Issue](https://github.com/Eleirbag89/TelegramBotPHP/issues/80) if you have made a bot using this API, I will add it to this section.
191228
* [Notifyadbot](https://telegram.me/notifyadbot) - Lang : Persian/Farsi (Down as 16/09/17)
192229
* [Partners_shakibonline_bot](https://telegram.me/Partners_shakibonline_bot) - Lang : Persian/Farsi (Down as 16/09/17)
@@ -204,12 +241,29 @@ Emoticons
204241
For a list of emoticons to use in your bot messages, please refer to the column Bytes of this table:
205242
http://apps.timwhitlock.info/emoji/tables/unicode
206243

244+
License
245+
------------
246+
247+
This open-source software is distributed under the MIT License. See LICENSE.md
248+
249+
Contributing
250+
------------
251+
252+
All kinds of contributions are welcome - code, tests, documentation, bug reports, new features, etc...
253+
254+
* Send feedbacks.
255+
* Submit bug reports.
256+
* Write/Edit the documents.
257+
* Fix bugs or add new features.
258+
207259
Contact me
208260
------------
261+
209262
You can contact me [via Telegram](https://telegram.me/ggrillo) but if you have an issue please [open](https://github.com/Eleirbag89/TelegramBotPHP/issues) one.
210263

211264
Support me
212265
------------
266+
213267
You can buy me a beer or two using [Paypal](https://paypal.me/eleirbag89)
214268
or support me using Flattr.
215269

0 commit comments

Comments
 (0)