New Ribbon
Canva+AI創意設計與品牌應用250招:從商業技巧、社群祕技到AI圖文影音特效 快快樂樂學威力導演2024.影音剪輯與AI精彩創作 文淵閣工作室祝福大家新年快樂.龍年吉祥 Power Automate自動化超效率工作術 Midjourney AI圖像魔導書:搭配ChatGPT魔法加倍 超人氣FB+IG+LINE社群經營與行銷力(第二版) 翻倍效率工作術:不會就太可惜的 Excel × ChatGPT 自動化應用 AppInventor2零基礎入門班中文版(第六版) Python零基礎入門班(第四版) C語言學習聖經 用Canva設計超快超質感:平面、網頁、電子書、簡報、影片製作與AI繪圖最速技 PHP8/MySQL網頁程式設計自學聖經 翻倍效率工作術 - 不會就太可惜的Power BI大數據視覺圖表設計與分析(第三版) 社群經營一定要會的影音剪輯與動畫製作術 Notion高效管理250招:筆記×資料庫×團隊協作,數位生活與工作最佳幫手 Office 2021高效實用範例必修16課(附500分鐘影音教學/範例檔) Excel自學聖經(第二版):從完整入門到職場活用的技巧與實例大全 網路開店×拍賣王:蝦皮來了(第二版) 專家都在用的Google最強實戰:表單、文件、試算、簡報、遠距與線上會議 超人氣 Instagram 視覺行銷力(第二版):小編不敗,經營 IG 品牌人氣王的 120 個秘技!

 

  Python 初學特訓班(第三版) LineBot

黃


更新時間:2019/6/19 下午 03:41:42

 

書中第十章LineBot

在linebot做Webhook URL測試一直失敗

=================================Internal Server Error: /callback
Traceback (most recent call last):
  File "H:\Anaconda3\lib\site-packages\django\core\handlers\exception.py", line 34, in inner
    response = get_response(request)
  File "H:\Anaconda3\lib\site-packages\django\core\handlers\base.py", line 115, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "H:\Anaconda3\lib\site-packages\django\core\handlers\base.py", line 113, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "H:\Anaconda3\lib\site-packages\django\views\decorators\csrf.py", line 54, in wrapped_view
    return view_func(*args, **kwargs)
  File "C:\Users\olpc38\linetestbot\linebotapi\views.py", line 28, in callback
    line_bot_api.reply_message(event.reply_token,TextSendMessage(text=event.message.text))
  File "H:\Anaconda3\lib\site-packages\linebot\api.py", line 100, in reply_message
    '/v2/bot/message/reply', data=json.dumps(data), timeout=timeout
  File "H:\Anaconda3\lib\site-packages\linebot\api.py", line 839, in _post
    self.__check_error(response)
  File "H:\Anaconda3\lib\site-packages\linebot\api.py", line 862, in __check_error
    raise LineBotApiError(response.status_code, error)
linebot.exceptions.LineBotApiError: LineBotApiError: status_code=400, error_response={"details": [], "message": "Invalid reply token"}
[19/Jun/2019 15:17:12] "POST /callback HTTP/1.1" 500 84393
==============================
HTTP Requests
-------------

POST /callback                 500 Internal Server Error
POST /callback                 500 Internal Server Error
POST /callback                 404 Not Found
POST /callback                 500 Internal Server Error
==============================

請問這是哪裡出了問題?謝謝

文淵閣工作室

文淵閣工作室
更新時間:2019/6/20 上午 08:54:06

 

錯誤訊息顯示是 28 列 reply_token 不正確。
請檢查你的 LINE_CHANNEL_ACCESS_TOKENLINE_CHANNEL_ACCESS_TOKEN 及 LINE_CHANNEL_SECRET)LINE_CHANNEL_SECRET) 設定正確嗎?

黃


更新時間:2019/6/20 上午 11:48:10

 

我重新生成新的token和secert試過也是一樣XD

文淵閣工作室

文淵閣工作室
更新時間:2019/6/20 下午 01:15:49

 

我們執行都正確無誤,目前無法判定您的問題所在。
請您檢查下列項目:
1. Available features 項目下是否有 REPLY_MESSAGE, PUSH_MESSAGE
2. Use webhooks 項目是否 Enable

黃


更新時間:2019/6/20 下午 02:39:06

 

我後來終於搞清楚問題出在哪裡了

https://github.com/line/line-bot-sdk-python/issues/37

This "Verify" means verifying SSL certificate.
When you click this verify-button, LINE server sends a dummy webhook.
And reply token included webhook is also dummy.
So, it is impossible to call reply API.

看到這段話我終於知道問題出在哪裡了

文淵閣工作室

文淵閣工作室
更新時間:2019/6/20 下午 04:17:40

 

抱歉!沒看清您指的是 develop 中的 verify,轉了好大一圈,sorry。

張


更新時間:2020/7/6 下午 07:24:12

 

前輩你們好:
目前也再拜讀此書,遇到了相同的問題,我想請教一下,萬一不小心按了Verify, 那我是不是重新執行ngrok, 然後重新update Webhook URL 就可以了? 當然 不要再按 Verify了,因爲我也不小心按了,照上述做法處理後問題仍存在,文內討論提到的重點,也都確認了,想多上來請教一下我有遺漏什麼嗎?

先說聲謝謝了🙏

文淵閣工作室

文淵閣工作室
更新時間:2020/7/7 上午 05:23:59

 

按 Verify 沒有任何作用,不必做任何處理,伓的問題應與按 Verify 無關。
請問您本機命令提示字元視窗的錯誤訊息是什麼?

張


更新時間:2020/7/8 下午 01:59:15

 

您好:
我的問題解決了, 主要是因為ngrok這段時間好像壞了, 我在論壇上看到有人討論, 後來有人提到可以改用ngrok http 8000 -host-header="localhost:8000" -region ap, 我試了一下就打通了

謝謝你的回覆
Have a nice day.

陳雋翔

陳雋翔
更新時間:2022/3/6 下午 09:14:57

 

在linebot 實做這章
我程式改了一點
改成:
for event in events:
            if isinstance(event, MessageEvent):
                
                line_bot_api.reply_message(event.reply_token, TextSendMessage(text="first message"))
                line_bot_api.reply_message(event.reply_token, TextSendMessage(text="second message"))
但是line端只有回應 first message, 並沒有出現 second message 的對話訊息

到了執行 manage.py 的命令視窗 出現的錯誤是
Internal Server Error: /callback
Traceback (most recent call last):
  File "C:\Users\88693\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\handlers\exception.py", line 47, in inner
    response = get_response(request)
  File "C:\Users\88693\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\handlers\base.py", line 181, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "C:\Users\88693\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\views\decorators\csrf.py", line 54, in wrapped_view
    return view_func(*args, **kwargs)
  File "D:\LineBot\linebotapi\views.py", line 36, in callback
    line_bot_api.reply_message(event.reply_token, TextSendMessage(text="second message"))
  File "C:\Users\88693\AppData\Local\Programs\Python\Python37-32\lib\site-packages\linebot\api.py", line 110, in reply_message
    '/v2/bot/message/reply', data=json.dumps(data), timeout=timeout
  File "C:\Users\88693\AppData\Local\Programs\Python\Python37-32\lib\site-packages\linebot\api.py", line 1622, in _post
    self.__check_error(response)
  File "C:\Users\88693\AppData\Local\Programs\Python\Python37-32\lib\site-packages\linebot\api.py", line 1663, in __check_error
    error=Error.new_from_json_dict(response.json)
linebot.exceptions.LineBotApiError: LineBotApiError: status_code=400, request_id=82ec654f-672d-401c-9604-731248d975f5, error_response={"details": [], "message": "Invalid reply token"}, headers={'Content-Type': 'application/json', 'Server': 'envoy', 'x-content-type-options': 'nosniff', 'x-frame-options': 'DENY', 'x-line-request-id': '82ec654f-672d-401c-9604-731248d975f5', 'x-xss-protection': '1; mode=block', 'Content-Length': '33', 'Expires': 'Sun, 06 Mar 2022 13:11:05 GMT', 'Cache-Control': 'max-age=0, no-cache, no-store', 'Pragma': 'no-cache', 'Date': 'Sun, 06 Mar 2022 13:11:05 GMT', 'Connection': 'close'}
[06/Mar/2022 21:11:05,385] - Broken pipe from ('127.0.0.1', 50493)

為什麼 是不能一次傳兩則嗎?

文淵閣工作室

文淵閣工作室
更新時間:2022/3/6 下午 10:03:39

 

同時傳送多個訊息時需將訊息置於串列中,語法範例:
message = [  #串列
TextSendMessage(  #傳送文字1
    text1 = "傳送文字1!"
),
TextSendMessage(  #傳送文字2
    text2 = "傳送文字2!"
),
]
line_bot_api.reply_message(event.reply_token,message)
您可參考本工作室書籍「Python與Linebot機器人全面實戰特訓班」5.2.6節

黃某某

黃某某
更新時間:2022/3/8 下午 02:13:25

 

我在實作第十章的~
如何做出如下功能?:
使用者輸入=>
bot回復(提問)=>
使用者回復(答案)=>
bot接收(根據回答回復)
ex:
我打:預約
bot回復:多久
我打:1小時
bot回復:好,幫你與約1小時

陳雋翔

陳雋翔
更新時間:2022/3/8 下午 05:50:39

 

Internal Server Error: /callback
Traceback (most recent call last):
  File "C:\Users\88693\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\handlers\exception.py", line 47, in inner
    response = get_response(request)
  File "C:\Users\88693\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\handlers\base.py", line 181, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "C:\Users\88693\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\views\decorators\csrf.py", line 54, in wrapped_view
    return view_func(*args, **kwargs)
  File "D:\LineBot\linebotapi\views.py", line 42, in callback
    line_bot_api.reply_message(event.reply_token,message)
  File "C:\Users\88693\AppData\Local\Programs\Python\Python37-32\lib\site-packages\linebot\api.py", line 110, in reply_message
    '/v2/bot/message/reply', data=json.dumps(data), timeout=timeout
  File "C:\Users\88693\AppData\Local\Programs\Python\Python37-32\lib\site-packages\linebot\api.py", line 1622, in _post
    self.__check_error(response)
  File "C:\Users\88693\AppData\Local\Programs\Python\Python37-32\lib\site-packages\linebot\api.py", line 1663, in __check_error
    error=Error.new_from_json_dict(response.json)
linebot.exceptions.LineBotApiError: LineBotApiError: status_code=400, request_id=3a475e53-0651-4afb-b3d7-a1fb70b1a916, error_response={"details": [{"message": "May not be empty", "property": "messages[0].text"}, {"message": "May not be empty", "property": "messages[1].text"}], "message": "The request body has 2 error(s)"}, headers={'Content-Type': 'application/json', 'Server': 'envoy', 'x-content-type-options': 'nosniff', 'x-frame-options': 'DENY', 'x-line-request-id': '3a475e53-0651-4afb-b3d7-a1fb70b1a916', 'x-xss-protection': '1; mode=block', 'Content-Length': '179', 'Expires': 'Tue, 08 Mar 2022 09:49:26 GMT', 'Cache-Control': 'max-age=0, no-cache, no-store', 'Pragma': 'no-cache', 'Date': 'Tue, 08 Mar 2022 09:49:26 GMT', 'Connection': 'close'}
[08/Mar/2022 17:49:27] "POST /callback HTTP/1.1" 500 82530

我把訊息放在list裡了,但還是出錯

陳雋翔

陳雋翔
更新時間:2022/3/8 下午 05:58:55

 

沒有問題了!
我用append 解決了~

陳雋翔

陳雋翔
更新時間:2022/3/8 下午 05:59:51

 

另外,有比ngrok更方便的嗎?
我沒次都要重開好麻煩

文淵閣工作室

文淵閣工作室
更新時間:2022/3/8 下午 09:45:52

 

抱欺!
1. linebot 是每次都從頭執行,故無法回覆連續問題。
2. 本機https轉址,ngrok操作算簡單的,目前不知可替代的元件。

章


更新時間:2022/3/11 下午 10:31:43

 

各位大大
有方法知道是誰傳送訊息嗎,我想製作歡迎訊息(ch10)

文淵閣工作室

文淵閣工作室
更新時間:2022/3/12 下午 05:44:39

 

可以取得傳訊息者的 line id,可自行找 line bot 專書學習。

章


更新時間:2022/3/12 下午 06:31:15

 

謝謝~

黃翊銓

黃翊銓
更新時間:2023/8/25 上午 01:35:45

 

from watchdog.events import EVENT_TYPE_OPENED

ImportError: cannot import name 'EVENT_TYPE_OPENED' from 'watchdog.events' (C:\ProgramData\anaconda3\Lib\site-packages\watchdog\events.py)


想請問資料表出現這則錯誤訊息該怎麼改

文淵閣工作室

文淵閣工作室
更新時間:2023/8/25 下午 05:43:50

 

請問是哪一本書的問題?
工作室沒有使用 watchdog 模組的書。

黃翊銓

黃翊銓
更新時間:2023/8/25 下午 09:22:27

 

不好意思,上面的問題好像是我操作錯誤出現的...
我現在是createdb能跑出成功訊息,但是換成page之後就找不到

文淵閣工作室

文淵閣工作室
更新時間:2023/8/26 下午 04:39:57

 

為了要快速能夠了解
請問是書上哪一頁的內容
謝謝




 

 

Re:Python 初學特訓班(第三版) LineBot

請輸入姓名。

已超出字元數目的最大值。


請輸入電子郵件。

格式無效。


請輸入內容。