1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types = 1); |
4
|
|
|
|
5
|
|
|
namespace unreal4u\TelegramAPI\Telegram\Methods; |
6
|
|
|
|
7
|
|
|
use Psr\Log\LoggerInterface; |
8
|
|
|
use unreal4u\TelegramAPI\Abstracts\TelegramMethods; |
9
|
|
|
use unreal4u\TelegramAPI\Abstracts\TelegramTypes; |
10
|
|
|
use unreal4u\TelegramAPI\InternalFunctionality\TelegramRawData; |
11
|
|
|
use unreal4u\TelegramAPI\Telegram\Types\Custom\ResultBoolean; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* Use this method to specify a url and receive incoming updates via an outgoing webhook. Whenever there is an update |
15
|
|
|
* for the bot, we will send an HTTPS POST request to the specified url, containing a JSON-serialized Update. In case of |
16
|
|
|
* an unsuccessful request, we will give up after a reasonable amount of attempts. |
17
|
|
|
* |
18
|
|
|
* If you'd like to make sure that the Webhook request comes from Telegram, we recommend using a secret path in the URL, |
19
|
|
|
* e.g. https://www.example.com/<token>. Since nobody else knows your bot‘s token, you can be pretty sure it’s us. |
20
|
|
|
* |
21
|
|
|
* Notes |
22
|
|
|
* <ul> |
23
|
|
|
* <li>You will not be able to receive updates using getUpdates for as long as an outgoing webhook is set up.</li> |
24
|
|
|
* <li>To use a self-signed certificate, you need to upload your public key certificate using certificate parameter. |
25
|
|
|
* Please upload as InputFile, sending a String will not work.</li> |
26
|
|
|
* <li>Ports currently supported for Webhooks: 443, 80, 88, 8443.</li> |
27
|
|
|
* </ul> |
28
|
|
|
* |
29
|
|
|
* Objects defined as-is july 2016 |
30
|
|
|
* |
31
|
|
|
* @see https://core.telegram.org/bots/api#setwebhook |
32
|
|
|
*/ |
33
|
|
|
class SetWebhook extends TelegramMethods |
34
|
|
|
{ |
35
|
|
|
/** |
36
|
|
|
* Optional. HTTPS url to send updates to. Use an empty string to remove webhook integration |
37
|
|
|
* @var string |
38
|
|
|
*/ |
39
|
|
|
public $url = ''; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* Optional. Upload your public key certificate so that the root certificate in use can be checked. See our |
43
|
|
|
* self-signed guide for details. |
44
|
|
|
* @var string |
45
|
|
|
*/ |
46
|
|
|
public $certificate = ''; |
47
|
|
|
|
48
|
1 |
|
public static function bindToObject(TelegramRawData $data, LoggerInterface $logger): TelegramTypes |
49
|
|
|
{ |
50
|
1 |
|
return new ResultBoolean($data->getResultBoolean(), $logger); |
51
|
|
|
} |
52
|
|
|
|
53
|
1 |
|
public function getMandatoryFields(): array |
54
|
|
|
{ |
55
|
1 |
|
return []; |
56
|
|
|
} |
57
|
|
|
} |
58
|
|
|
|