Giter VIP home page Giter VIP logo

telegram-bot-api's People

Contributors

dzayatc avatar mehrdad-dadkhah avatar mirhadi avatar mirocow avatar zelenin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

telegram-bot-api's Issues

missed quote in usage example

In readme in "Usage" section you missed a single quote after "Test message". That's why highlighting isn't working there.

$response = $client->sendMessage([
        'chat_id' => $chatId,
        'text' => 'Test message  // <- here you are
    ]);

Exception 'GuzzleHttp\Exception\ServerException' with message 'Server error: `POST

Exception 'GuzzleHttp\Exception\ServerException' with message 'Server error: `POST https://api.telegram.org/uuuuuu:iiiiiiiiiiiiii/getUpdates` resulted in a `502 Bad Gateway` response:
<html>
<head><title>502 Bad Gateway</title></head>
<body bgcolor="white">
<center><h1>502 Bad Gateway</h1></center>
 (truncated...)
'

in /home/101112.pw/httpdocs/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php:107

Stack trace:
#0 /home/101112.pw/httpdocs/vendor/guzzlehttp/guzzle/src/Middleware.php(65): GuzzleHttp\Exception\RequestException::create(Object(GuzzleHttp\Psr7\Request), Object(GuzzleHttp\Psr7\Response))
#1 /home/101112.pw/httpdocs/vendor/guzzlehttp/promises/src/Promise.php(201): GuzzleHttp\Middleware::GuzzleHttp\{closure}(Object(GuzzleHttp\Psr7\Response))
#2 /home/101112.pw/httpdocs/vendor/guzzlehttp/promises/src/Promise.php(154): GuzzleHttp\Promise\Promise::callHandler(1, Object(GuzzleHttp\Psr7\Response), Array)
#3 /home/101112.pw/httpdocs/vendor/guzzlehttp/promises/src/TaskQueue.php(61): GuzzleHttp\Promise\Promise::GuzzleHttp\Promise\{closure}()
#4 /home/101112.pw/httpdocs/vendor/guzzlehttp/promises/src/Promise.php(242): GuzzleHttp\Promise\TaskQueue->run(true)
#5 /home/101112.pw/httpdocs/vendor/guzzlehttp/promises/src/Promise.php(219): GuzzleHttp\Promise\Promise->invokeWaitFn()
#6 /home/101112.pw/httpdocs/vendor/guzzlehttp/promises/src/Promise.php(262): GuzzleHttp\Promise\Promise->waitIfPending()
#7 /home/101112.pw/httpdocs/vendor/guzzlehttp/promises/src/Promise.php(221): GuzzleHttp\Promise\Promise->invokeWaitList()
#8 /home/101112.pw/httpdocs/vendor/guzzlehttp/promises/src/Promise.php(62): GuzzleHttp\Promise\Promise->waitIfPending()
#9 /home/101112.pw/httpdocs/vendor/guzzlehttp/guzzle/src/Client.php(129): GuzzleHttp\Promise\Promise->wait()
#10 /home/101112.pw/httpdocs/vendor/guzzlehttp/guzzle/src/Client.php(87): GuzzleHttp\Client->request('post', 'https://api.tel...', Array)
#11 /home/101112.pw/httpdocs/vendor/zelenin/telegram-bot-api/Client.php(50): GuzzleHttp\Client->__call('post', Array)
#12 /home/101112.pw/httpdocs/vendor/zelenin/telegram-bot-api/Client.php(50): GuzzleHttp\Client->post('https://api.tel...', Array)
#13 /home/101112.pw/httpdocs/vendor/zelenin/telegram-bot-api/Api.php(44): Zelenin\Telegram\Bot\Client->request('getUpdates', Array)
#14 /home/101112.pw/httpdocs/vendor/zelenin/telegram-bot-api/Api.php(259): Zelenin\Telegram\Bot\Api->request('getUpdates', Array)
#15 /home/101112.pw/httpdocs/vendor/zelenin/telegram-bot-api/Daemon/Daemon.php(68): Zelenin\Telegram\Bot\Api->getUpdates(Array)
#16 /home/101112.pw/httpdocs/vendor/zelenin/telegram-bot-api/Daemon/Daemon.php(55): Zelenin\Telegram\Bot\Daemon\Daemon::getUpdates()
#17 [internal function]: Zelenin\Telegram\Bot\Daemon\Daemon->Zelenin\Telegram\Bot\Daemon\{closure}('0000000034ef15d...', NULL)
#18 /home/101112.pw/httpdocs/vendor/amphp/amp/lib/NativeReactor.php(288): call_user_func(Object(Closure), '0000000034ef15d...', NULL)
#19 /home/101112.pw/httpdocs/vendor/amphp/amp/lib/NativeReactor.php(221): Amp\NativeReactor->executeTimers()
#20 /home/101112.pw/httpdocs/vendor/amphp/amp/lib/NativeReactor.php(70): Amp\NativeReactor->doTick(false)
#21 /home/101112.pw/httpdocs/vendor/amphp/amp/lib/functions.php(46): Amp\NativeReactor->run(Object(Closure))
#22 /home/101112.pw/httpdocs/vendor/zelenin/telegram-bot-api/Daemon/Daemon.php(60): Amp\run(Object(Closure))
#23 /home/101112.pw/httpdocs/vendor/mirocow/yii2-telegram-api/src/controllers/BotController.php(87): Zelenin\Telegram\Bot\Daemon\Daemon->run()
#24 [internal function]: mirocow\telegram\controllers\BotController->actionIndex()
#25 /home/101112.pw/httpdocs/vendor/yiisoft/yii2/base/InlineAction.php(55): call_user_func_array(Array, Array)
#26 /home/101112.pw/httpdocs/vendor/yiisoft/yii2/base/Controller.php(154): yii\base\InlineAction->runWithParams(Array)
#27 /home/101112.pw/httpdocs/vendor/yiisoft/yii2/console/Controller.php(119): yii\base\Controller->runAction('', Array)
#28 /home/101112.pw/httpdocs/vendor/yiisoft/yii2/base/Module.php(454): yii\console\Controller->runAction('', Array)
#29 /home/101112.pw/httpdocs/vendor/yiisoft/yii2/console/Application.php(167): yii\base\Module->runAction('telegram/bot', Array)
#30 /home/101112.pw/httpdocs/vendor/yiisoft/yii2/console/Application.php(143): yii\console\Application->runAction('telegram/bot', Array)
#31 /home/101112.pw/httpdocs/vendor/yiisoft/yii2/base/Application.php(375): yii\console\Application->handleRequest(Object(yii\console\Request))
#32 /home/101112.pw/httpdocs/yii(23): yii\base\Application->run()
#33 {main}

new line notwork in this project

hi new line for telegram message send not work

please fix it and or show me other method for send message white new line

thak you ..

NotOkException

this error is on my server logs and repeated
PHP Fatal error: Uncaught Zelenin\Telegram\Bot\Exception\NotOkException: Code: 403. Description: "Bot was blocked by the user". in /app/vendor/zelenin/telegram-bot-api/Api.php:43

and catch is this :

catch (\Zelenin\Telegram\Bot\NotOkException $e) {
        $logger->addInfo('catch error:'.$e->getMessage());
}

catch not work and error repeat on server logs

what should I do?

error server

when i use your newest library , this code show me Error server,
But when i use your oldest version , show "Code: 400. Description: "[Error]: Bad Request: chat_id is empty" and works fine !
please help me to work with your newes library !

Code :
require 'vendor/autoload.php';
require 'lib/config.php'
$client = new Zelenin\Telegram\Bot\Api($token); // Set your access token
$update = json_decode(file_get_contents('php://input'));
try {
$test = 'dgd';
$response = $client->sendMessage([
'chat_id' => $update->message->chat->id,
'text' => $test
]);
} catch (\Zelenin\Telegram\Bot\NotOkException $e) {
echo $e->getMessage();
}

keboard markup help

hi
first I want to thank for this nice library.
for my bot i need to make keyboard markup but i'm not sure how to do it.
I tried this but it didn't work:

$keyboard = array(
    'keyboard' => array(
        array("A", "B")
    )
);
$client->sendMessage(array('chat_id' => $chatid, 'text' => 'test', 'reply_markup' => $keyboard));

Keybord problem

Hi!
When I'm trying send message with inlineKeyboard (using reply_markup).

...
$buttons[] = [new InlineKeyboardButton([
                'text' => $route->name,
                'callback_data' => $route->id
            ])];
...
'reply_markup' => new InlineKeyboardMarkup(['inline_keyboard' => $buttons])
...

I'm getting an error

Code: 400. Description: "Bad Request: can't parse inline keyboard button: Field "url" must be of type String

Coz reply_markup contains all params including empty url and switch_inline_query

[reply_markup] => {"inline_keyboard":[[{"text":"Www","url":null,"callback_data":1,"switch_inline_query":null}]]}

How I can use a webhook method?

Hello.
I want to use my bot with webhook method not with getUpdates.
It works very good with your deamon approach.
Also it works with this component and its method https://github.com/unreal4u/telegram-api/wiki/Getting-updates-via-Webhook
I tried do somethimg like this

use Zelenin\Telegram\Bot\Type\Update;

$update = new Update($_POST);

but it doesn't work.
I got an error:

TypeError: Argument 1 passed to Zelenin\Telegram\Bot\Type\Type::create() must be an instance of stdClass, array given, called in /var/www/telegram/vendor/zelenin/telegram-bot-api/Type/Update.php on line 60 and defined in /var/www/telegram/vendor/zelenin/telegram-bot-api/Type/Type.php:51

leave a group function

I write in php
$response = $api->leaveChat();
but console says
PHP Fatal error: Uncaught Error: Call to undefined method Zelenin\Telegram\Bot\Api::leaveChat()

Can you tell me the correct way to use this function?

timeout request larg file

my codes for sending audio file is like this

$url = 'http://test/test.mp3';

sendAudio([
'audio' => fopen($url ,'r')
]);

it works great for small files but if url file is larger than 5 Mb I have request timeout error on server logs and it sends that file many time because of looping

I use heroku

upgrade telegram-bot-api

after update to version 1.0
$client = new Zelenin\Telegram\Bot\Api($token); display this error:
PHP Fatal error: Uncaught TypeError: Argument 1 passed to Zelenin\Telegram\Bot\Api::__construct() must be an instance of Zelenin\Telegram\Bot\Client\Client, string given, called in /app/index.php on line 26 and defined in /app/vendor/zelenin/telegram-bot-api/Api.php:26
what should I do?

send file with file_id

when i want to send a document with url or link , i use this code :

$client -> sendDocument(array('chat_id' => $chatid, 'document' => fopen($link, 'r')));

But now i want to know , How i can send file with file_id ? for Ex : BQADBAAD7QIAAoFEJAXq2UtTclEUhQI

i test this code :
$client -> sendDocument(array('chat_id' => $chatid, 'document' => 'BQADBAAD7QIAAoFEJAXq2UtTclEUhQI'));

but's not working !
plz help me !
Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.