1
1
# whatsapp-api-webhook-server-golang
2
2
3
- whatsapp-api-webhook-server-golang - библиотека для интеграции с мессенджером WhatsApp через API
4
- сервиса [ green-api.com] ( https://green-api.com/ ) . Чтобы воспользоваться библиотекой, нужно получить регистрационный токен
5
- и ID аккаунта в [ личном кабинете] ( https://console.green-api.com/ ) . Есть бесплатный тариф аккаунта разработчика.
3
+ - [ Документация на русском языке] ( docs/README_RU.md ) .
4
+
5
+ whatsapp-api-webhook-server-golang is a library for integration with WhatsApp messenger using the API
6
+ service [ green-api.com] ( https://green-api.com/en/ ) . You should get a registration token and an account ID in
7
+ your [ personal cabinet] ( https://console.green-api.com/ ) to use the library. There is a free developer account tariff.
6
8
7
9
## API
8
10
9
- Документация к REST API находится по [ ссылке ] ( https://green-api.com/docs/api/ ) . Библиотека является оберткой к REST API,
10
- поэтому документация по ссылке выше применима и к самой библиотеке .
11
+ The documentation for the REST API can be found at the [ link ] ( https://green-api.com/en/ docs/ ) . The library is a wrapper
12
+ for the REST API, so the documentation at the link above also applies .
11
13
12
- ## Авторизация
14
+ ## Authorization
13
15
14
- Чтобы отправить сообщение или выполнить другие методы Green API, аккаунт WhatsApp в приложении телефона должен быть в
15
- авторизованном состоянии. Для авторизации аккаунта перейдите в [ личный кабинет] ( https://console.green-api.com/ ) и
16
- сканируйте QR-код с использованием приложения WhatsApp.
16
+ To send a message or perform other Green API methods, the WhatsApp account in the phone app must be authorized. To
17
+ authorize the account, go to your [ cabinet] ( https://console.green-api.com/ ) and scan the QR code using the WhatsApp app.
17
18
18
- ## Пример подготовки среды для Ubuntu Server
19
+ ## Example of preparing the environment for Ubuntu Server
19
20
20
- ### Установка Go
21
+ ### Go Installation
21
22
22
- На сервере должен быть установлен Go . [ Инструкция по установке Go ] ( https://go.dev/doc/install ) .
23
+ Go must be installed on the server . [ Go installation instructions ] ( https://go.dev/doc/install ) .
23
24
24
- ### Обновление системы
25
+ ### Updating the system
25
26
26
- Обновим систему :
27
+ Update the system :
27
28
28
29
``` shell
29
30
sudo apt update
30
31
sudo apt upgrade -y
31
32
```
32
33
33
- ### Брандмауэр
34
+ ### Firewall
34
35
35
- Настроим брандмауэр :
36
+ Set up the firewall :
36
37
37
- Разрешим соединение по SSH:
38
+ Allow the SSH connection :
38
39
39
40
``` shell
40
41
sudo ufw allow ssh
41
42
```
42
43
43
- Базовые правила :
44
+ Base rules :
44
45
45
46
``` shell
46
47
sudo ufw default deny incoming
47
48
sudo ufw default allow outgoing
48
49
```
49
50
50
- Разрешаем соединения по HTTP и HTTPS:
51
+ Allow HTTP and HTTPS connections :
51
52
52
53
``` shell
53
54
sudo ufw allow http
54
55
sudo ufw allow https
55
56
```
56
57
57
- Активируем брандмауэр :
58
+ Enable the firewall :
58
59
59
60
``` shell
60
61
sudo ufw enable
61
62
```
62
63
63
- ## Как запустить веб-сервер
64
+ ## How to run the web server
64
65
65
- ### Установка
66
+ ### Installation
66
67
67
- Не забудьте создать модуль :
68
+ Do not forget to create a module :
68
69
69
70
``` shell
70
71
go mod init example
71
72
```
72
73
73
- Установка :
74
+ Installation :
74
75
75
76
``` shell
76
77
go get github.com/green-api/whatsapp-api-webhook-server-golang
77
78
```
78
79
79
- ### Импорт
80
+ ### Import
80
81
81
82
```
82
83
import (
83
84
"github.com/green-api/whatsapp-api-webhook-server-golang/pkg"
84
85
)
85
86
```
86
87
87
- ### Примеры
88
+ ### Examples
88
89
89
- #### Как инициализировать объект
90
+ #### How to initialize an object
90
91
91
- Атрибут WebhookToken является опциональным .
92
+ The WebhookToken attribute is optional .
92
93
93
94
```
94
95
webhook := pkg.Webhook{
@@ -97,32 +98,32 @@ webhook := pkg.Webhook{
97
98
}
98
99
```
99
100
100
- #### Как запустить веб-сервер
101
+ #### How to run the web server
101
102
102
- Функция StartServer принимает функцию-обработчик. Функция-обработчик должна содержать 1
103
- параметр (` body map[string]interface{} ` ). При получении нового уведомления ваша функция-обработчик будет выполнена .
103
+ The StartServer function takes a handler function. The handler function must have 1
104
+ parameter (` body map[string]interface{} ` ). When a new notification is received, your handler function will be executed .
104
105
105
- Ссылка на пример : [ main.go] ( examples/main.go ) .
106
+ Link to example : [ main.go] ( examples/main.go ) .
106
107
107
108
```
108
109
_ := webhook.StartServer(func(body map[string]interface{}) {
109
110
fmt.Println(body)
110
111
})
111
112
```
112
113
113
- ### Запуск приложения
114
+ ### Running the application
114
115
115
116
``` shell
116
117
go run main.go
117
118
```
118
119
119
- ## Документация по методам сервиса
120
+ ## Service methods documentation
120
121
121
- [ Документация по методам сервиса ] ( https://green-api.com/docs/api/ )
122
+ [ Service methods documentation ] ( https://green-api.com/en /docs/api/ )
122
123
123
- ## Лицензия
124
+ ## License
124
125
125
- Лицензировано на условиях [
126
+ Licensed under [
126
127
Attribution-NoDerivatives 4.0 International (CC BY-ND 4.0)
127
- ] ( https://creativecommons.org/licenses/by-nd/4.0/ ) .
128
- Смотрите файл [ LICENSE] ( LICENSE ) .
128
+ ] ( https://creativecommons.org/licenses/by-nd/4.0/ ) terms .
129
+ Please see file [ LICENSE] ( LICENSE ) .
0 commit comments