Comments (10)
HI, sorry for late response.
Could you tell us your way how to verify and error log if it was produced.
Thanks.
from line-bot-sdk-python.
It seems that you can't use the "Verify" button in console if you call the Reply API.
Using the same code as written in README.rst
:
from flask import Flask, request, abort
from linebot import (
LineBotApi, WebhookHandler
)
from linebot.exceptions import (
InvalidSignatureError
)
from linebot.models import (
MessageEvent, TextMessage, TextSendMessage,
)
app = Flask(__name__)
line_bot_api = LineBotApi('YOUR_CHANNEL_ACCESS_TOKEN')
handler = WebhookHandler('YOUR_CHANNEL_SECRET')
@app.route("/callback", methods=['POST'])
def callback():
# get X-Line-Signature header value
signature = request.headers['X-Line-Signature']
# get request body as text
body = request.get_data(as_text=True)
app.logger.info("Request body: " + body)
# handle webhook body
try:
handler.handle(body, signature)
except InvalidSignatureError:
abort(400)
return 'OK'
@handler.add(MessageEvent, message=TextMessage)
def handle_message(event):
line_bot_api.reply_message(
event.reply_token,
TextSendMessage(text=event.message.text))
if __name__ == "__main__":
app.run()
or the flask-echo
example app, verifying the Webhook in Console always returns the error saying that the server returns an invalid response.
However, deleting
line_bot_api.reply_message(
event.reply_token,
TextSendMessage(text=event.message.text))
will make the verification successful, but of course the bot won't do anything when it receives a message.
In your example, the callback function will return 'ok get'
(or 'ok post'
, I don't know why you wrote this) and exit right away, therefore handler.handle(body, signature)
won't be processed and Reply API won't be called, and Webhook verification will succeed.
Question is:
Is it possible to do Webhook verification AND calling the Reply API at the same time?
(I think this is related to #37).
from line-bot-sdk-python.
Hmm I'll try to propose an idea to fix this issue. Currently, my PR #80 failed in CI.
from line-bot-sdk-python.
I am also facing this issue. The bot will not join any group chat without webhook working properly, as well as the verify button not working properly in the development console. Would be great if this could be fixed!
from line-bot-sdk-python.
Because the replyToken and userId contained in the verify button are dummy data, if you use API to call it, it becomes error.
This button is used for confirming the connection. (Including SSL setting)
from line-bot-sdk-python.
To clarify, you think that only the Verify button is broken and webhook does actually work? Is there another reason the bot won't join group chats? And why does the verify button work for the java version of the bot's sdk, but not the python sdk? @mgilangjanuar - do you think this issue should be closed, or does further work need to be done?
from line-bot-sdk-python.
Is there another reason the bot won't join group chats?
Could you check this setting ?
(Default is Disabled
)
And why does the verify button work for the java version of the bot's sdk, but not the python sdk?
Java SDK(with spring-boot) handles exception and always return 200.
If you want to do the same action in python, please handle the exception as follows.
@app.route("/callback", methods=['POST'])
def callback():
signature = request.headers['X-Line-Signature']
# get request body as text
body = request.get_data(as_text=True)
app.logger.info("Request body: " + body)
try:
events = parser.parse(body, signature)
for event in events:
if not isinstance(event, MessageEvent):
continue
if not isinstance(event.message, TextMessage):
continue
line_bot_api.reply_message(
event.reply_token,
TextSendMessage(text=event.message.text)
)
except:
# handle all exception
print("Unexpected error:", sys.exc_info()[0])
return 'OK'
from line-bot-sdk-python.
@trumad alternatively, you can install with pip install -e git+https://github.com/mgilangjanuar/line-bot-sdk-python.git@master#egg=line_bot_sdk
😆✌️
from line-bot-sdk-python.
Thanks guys for your quick replies. The bot is enabled for joining group chats, yes. I'll hopefully get a chance to work on this project again tomorrow night given this new information. Thanks!
from line-bot-sdk-python.
@be-hase i need your help i've emailed you my problem, can you please contact me ??
from line-bot-sdk-python.
Related Issues (20)
- how to create a multiline text in a textmessage HOT 2
- Update version on release HOT 1
- i use the demo but it show me the alert HTTP response body: {"message":"Invalid reply token"} HOT 2
- I've got error HOT 2
- OSError: write error HOT 17
- Difference between func() and func_with_http_info() HOT 1
- Async with @handle decorator in linebot.v3 HOT 2
- quote tokens的調用方式 HOT 3
- Can't install this pool in python 3.12 HOT 3
- `to_json` method of Flex Object escapes Japanese characters HOT 3
- Adding new language support to documentation HOT 2
- it seems like there is no way to issue ChannelAccessToken with this SDK HOT 3
- How to save a GIF image in flask-kitchensink HOT 2
- Cannot get `Content-Type` in `MessagingApiBlob().get_message_content()`. HOT 2
- How to used ClipboardAction? HOT 3
- publishing line-bot-sdk-python v3.10.0 failed HOT 1
- Can't override DATA_URL in v3 package
- test
- Create new example for an echo-bot using AWS Lambda Functions, `linebot.v3` HOT 1
- pip install line-bot-sdk
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from line-bot-sdk-python.