Commit 307768c5 authored by MBoretto's avatar MBoretto

Added unset webhook

parent 5928fa18
...@@ -331,7 +331,8 @@ You can overwrite the default Upload and Download directory with: ...@@ -331,7 +331,8 @@ You can overwrite the default Upload and Download directory with:
$telegram->setDownloadPath("yourpath/Download"); $telegram->setDownloadPath("yourpath/Download");
$telegram->setUploadPath("yourpath../Upload"); $telegram->setUploadPath("yourpath../Upload");
``` ```
###Unset Webhook
Edit *example-unset.php* with your credential and execute it.
### Logging ### Logging
Thrown Exception are stored in TelegramException.log file (in the base directory). Thrown Exception are stored in TelegramException.log file (in the base directory).
......
<?php
//Composer Loader
$loader = require __DIR__.'/vendor/autoload.php';
$API_KEY = 'your_bot_api_key';
$BOT_NAME = 'namebot';
try {
// create Telegram API object
$telegram = new Longman\TelegramBot\Telegram($API_KEY, $BOT_NAME);
// set webhook
$result = $telegram->unsetWebHook();
//Uncomment to use certificate
//$result = $telegram->setWebHook($link, $path_certificate);
if ($result->isOk()) {
echo $result->getDescription();
}
} catch (Longman\TelegramBot\Exception\TelegramException $e) {
echo $e;
}
...@@ -395,11 +395,8 @@ class Request ...@@ -395,11 +395,8 @@ class Request
return $result; return $result;
} }
public static function setWebhook($url, $file = null) public static function setWebhook($url='', $file = null)
{ {
if (empty($url)) {
throw new TelegramException('Url is empty!');
}
$data['url'] = $url; $data['url'] = $url;
if (!is_null($file)) { if (!is_null($file)) {
......
...@@ -716,6 +716,23 @@ class Telegram ...@@ -716,6 +716,23 @@ class Telegram
return $result; return $result;
} }
/**
* Unset Webhook for bot
*
* @return string
*/
public function unsetWebHook()
{
$result = Request::setWebhook();
if (!$result->isOk()) {
throw new TelegramException(
'Webhook was not unset! Error: '.$result->getErrorCode().' '. $result->getDescription()
);
}
return $result;
}
/** /**
* Get available message types * Get available message types
* *
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment