-
Notifications
You must be signed in to change notification settings - Fork 671
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Problem in setting up web hook at Telegram #23
Comments
Can you post your code? Without that it would be hard to tell where the problem could be. Also do you use it with Laravel or just standalone? Maybe share your log as well. |
Yes this is my code:
Now if a user send Message to my Bot ,"Thanks" Message always send to the user!! |
Try this, it works for me:
|
Thanks @defunctl |
It's an object of this package. https://github.com/irazasyed/telegram-bot-sdk/blob/master/src/Objects/Message.php |
@hamo0n It seems like you're using Laravel? Here's how i would do that: $update = Telegram::getWebhookUpdates();
$chat_id = $update->getMessage()->getChat()->getId();
Telegram::sendMessage($chat_id, "Thanks", false, null, null);
return response()->json(["status" => "success"]); @defunctl The library will automatically map all the relations to the appropriate object class, So you don't have to map it again. So when you make a call to $chat_id = $update->getMessage()->getChat()->getId(); |
@hamo0n If your script returns any Error and status code other than 200 which it does based on your code, Then Telegram servers assume the update wasn't accepted and failed from your end. So they end up retrying for a few times, due to which you're getting that message multiple times. FYI. |
thanks @irazasyed But the problem still remains :(
|
It seems like you're working on commands area, Why don't you use the built in commands system that i pushed recently? Check this comment i made here, It's in development, So you need to follow all the instructions there and try. |
BTW, Laravel has CSRF Middleware protection for any POST routes ON by default. You need to make sure you add your route to the |
I commented VerifyCsrfToken because of this. Edit:
you know last day It was Ok and worked ! |
Well, It's a problem from your end as i tested and I'm using this with my bots too. It's working absolutely fine. Now how you've implemented is something i have no idea about. You're giving me parts of the codes and based on that, I've suggested you on how to go about it. |
@irazasyed. This package works fine on my local host. |
Okay! Let me know if you find a problem with this SDK. Please create a new issue ticket. Thanks! |
@shankar96 Not sure why you're asking about node.js in a php project? But anyway, Telegram tries to resend the message until you respond it with header status code 200, once you do that, their system thinks you accepted the update. Just do that and it'll stop it. |
hi thank you |
I have the same problem and have no idea why ?! exception 'ErrorException' with message 'Undefined offset: 0' in /var/www/shokraneh/vendor/irazasyed/telegram-bot-sdk/src/Api.php:1057 try { Help please |
Make sure you are using v3.0.0 |
I've designed a robot for Telegram.
After setting up web hook and sending messages to this robot, the robot response me as repetitious, as if the response of robot is on loop.
My code is simple, but I don’t know why telegram sends duplicate massages for my web hook.
The text was updated successfully, but these errors were encountered: