Answer the question
In order to leave comments, you need to log in
Why does a POST API request return the html code of the page?
I'm trying to set up a telegram bot. I am using php-telegram-bot in laravel project. I hung up a webhook using a certificate, I run: https://api.telegram.org/....../getWebhookInfo
, an error is generated:
{
"ok": true,
"result": {
"url": "https://..../api/telegram/hook/",
"has_custom_certificate": true,
"pending_update_count": 14,
"last_error_date": 1549036967,
"last_error_message": "Wrong response from the webhook: 301 Moved Permanently",
"max_connections": 40
}
}
public function hook()
{
$commands_paths = [
app_path() . '/Telegram/Bots/Bitbd_BOT/Commands',
];
try {
// Create Telegram API object
$telegram = new Telegram($this->bot_api_key, $this->bot_username);
TelegramLog::initErrorLog(storage_path() . "/{$this->bot_username}_error.log");
TelegramLog::initDebugLog(storage_path() . "/{$this->bot_username}_debug.log");
TelegramLog::initUpdateLog(storage_path() . "/{$this->bot_username}_update.log");
// Add commands paths containing your custom commands
$telegram->addCommandsPaths($commands_paths);
$telegram->enableLimiter();
// Handle telegram webhook request
$telegram->handle();
} catch (TelegramException $e) {
echo $e->getMessage();
}
}
Route::group(['prefix' => 'telegram'], function () {
Route::any('hook/set', '[email protected]');
Route::post('hook','[email protected]');
});
Route::get('hook','[email protected]');
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question