php-telegram-bot / core

PHP Telegram Bot based on the official Telegram Bot API
MIT License
3.9k stars 955 forks source link

set.php problem #336

Closed MadAlexk closed 7 years ago

MadAlexk commented 7 years ago

Required Information

Expected behaviour

What SHOULD be happening?

On set UP: https://......AAEtT4Rh2eBTPakzJOo0bkFk3A-6pxaEErk/set.php

PHP Fatal error: Uncaught Error: Call to a member function getBody() on null in C:\inetpub\WWW.....\63AAEtT4Rh2eBTPakzJOo0bkFk3A-6pxaEErk\vendor\longman\telegram-bot\src\Request.php:227 Stack trace:

0 C:\inetpub\WWW.....\63AAEtT4Rh2eBTPakzJOo0bkFk3A-6pxaEErk\vendor\longman\telegram-bot\src\Request.php(316): Longman\TelegramBot\Request::execute('setWebhook', Array)

1 C:\inetpub\WWW.....\63AAEtT4Rh2eBTPakzJOo0bkFk3A-6pxaEErk\vendor\longman\telegram-bot\src\Request.php(814): Longman\TelegramBot\Request::send('setWebhook', Array)

2 C:\inetpub\WWW.....\63AAEtT4Rh2eBTPakzJOo0bkFk3A-6pxaEErk\vendor\longman\telegram-bot\src\Telegram.php(742): Longman\TelegramBot\Request::setWebhook('https://........', 'C:\inetpub\WWW\...')

3 C:\inetpub\WWW.....\63AAEtT4Rh2eBTPakzJOo0bkFk3A-6pxaEErk\set.php(19): Longman\TelegramBot\Telegram->setWebHook('https://........', 'C:\inetpub\WWW\...')

4 {main}

thrown in C:\inetpub\WWW.....\63AAEtT4Rh2eBTPakzJOo0bkFk3A-6pxaEErk\vendor\longman\telegram-bot\src\Request.php on line 227


<?php // Load composer require DIR . '/vendor/autoload.php';

$API_KEY = 'T4Rh2eBTPakzJOo0bkFk3A-6pxaEErk'; $BOT_NAME = '....st1Bot'; $hook_url = 'https://.......63AAEtT4Rh2eBTPakzJOo0bkFk3A-6pxaEErk/hook.php'; $path_certificate = DIR . '/win_webhook_cert.cer'; echo "hook_url:".$hook_url;

try { // Create Telegram API object $telegram = new Longman\TelegramBot\Telegram($API_KEY, $BOT_NAME);

// Set webhook
//$result = $telegram->setWebHook($hook_url);

// Uncomment to use certificate

$result = $telegram->setWebHook($hook_url, $path_certificate);

if ($result->isOk()) {
    echo $result->getDescription();
}

} catch (Longman\TelegramBot\Exception\TelegramException $e) { echo $e; }

noplanman commented 7 years ago

edit: #536 allows you to disable verification without modifying core files, please use that instead!


I'm guessing this is related to the fact that you're using Windows. Unfortunately I don't have a Windows installation to test this, but either way the library won't work with Windows. It's laid out for *nix type systems.

MadAlexk commented 7 years ago

i am sad. But why?

Php works with it - not a windows :(( i can give ftp for you, do you want to look on it?

noplanman commented 7 years ago

I don't think Windows is on the todo list for us.

Most PHP webservers run on some distribution of nux, which is the most stable way of running it. I urge you to look into a nix server for hosting your bot. Alternatively, you can install VirtualBox on your Windows computer and install it there.

There should be enough information around on the internet on how to do that 😊

jacklul commented 7 years ago

I disagree on not supporting Windows, there are people who prefer Windows environment over Linux.

noplanman commented 7 years ago

@jacklul Ok, I understand what you mean. For me though, my Windows days are pretty much over, so I'll leave this open for others to implement.

jacklul commented 7 years ago

production unsafe (?) workaround: https://github.com/jacklul/php-telegram-bot/commit/46baa111cc59fcb623f5d8653bfb883f8fb183b8