{"id":127,"date":"2025-05-28T13:04:52","date_gmt":"2025-06-04T06:00:52","guid":{"rendered":"https:\/\/badgameshow.com\/steven\/?p=127"},"modified":"2025-06-04T13:04:52","modified_gmt":"2025-06-04T06:00:52","slug":"line-bot-%e9%80%a3%e5%8b%95-line-notify-mac%e5%ae%89%e8%a3%9d","status":"publish","type":"post","link":"https:\/\/badgameshow.com\/steven\/line\/line-bot-%e9%80%a3%e5%8b%95-line-notify-mac%e5%ae%89%e8%a3%9d\/","title":{"rendered":"\u4f7f\u7528 Python \u5728 Mac \u4e0a\u8a2d\u7f6e Line Bot \u9023\u63a5 Line Notify \u7684\u5b8c\u6574\u6307\u5357"},"content":{"rendered":"<h3>1. \u4f7f\u7528 Homebrew \u5b89\u88dd ngrok<\/h3>\n<p>\u9996\u5148\uff0c\u60a8\u9700\u8981\u4f7f\u7528 Homebrew \u4f86\u5b89\u88dd ngrok\u3002ngrok \u662f\u4e00\u500b\u975e\u5e38\u6709\u7528\u7684\u5de5\u5177\uff0c\u53ef\u4ee5\u5e6b\u52a9\u60a8\u5feb\u901f\u5efa\u7acb\u672c\u5730\u958b\u767c\u74b0\u5883\u7684\u96a7\u9053\uff0c\u8b93\u60a8\u7684\u61c9\u7528\u7a0b\u5f0f\u80fd\u5920\u63a5\u6536\u4f86\u81ea\u4e92\u806f\u7db2\u7684\u8acb\u6c42\u3002<\/p>\n<pre><code class=\"line-numbers\">brew install --cask ngrok\n<\/code><\/pre>\n<h3>2. \u5b89\u88dd Node.js<\/h3>\n<p>\u63a5\u4e0b\u4f86\uff0c\u60a8\u9700\u8981\u5b89\u88dd Node.js\uff0c\u5b83\u662f\u904b\u884c Line Bot \u7684\u57fa\u790e\u74b0\u5883\u3002<\/p>\n<pre><code class=\"line-numbers\">brew install node\n<\/code><\/pre>\n<h3>3. \u4e0b\u8f09 Line Bot SDK \u7bc4\u4f8b<\/h3>\n<p>\u8a2a\u554f\u5b98\u65b9 GitHub \u9801\u9762\uff0c\u4e0b\u8f09 Line Bot SDK \u7684 Node.js \u7bc4\u4f8b\uff0c\u6216\u8005\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u76f4\u63a5\u514b\u9686\u5b58\u5132\u5eab\uff1a<\/p>\n<blockquote><p>\n  <a href=\"https:\/\/github.com\/line\/line-bot-sdk-nodejs\" title=\"Line Bot SDK \u7bc4\u4f8b GitHub\" target=\"_blank\" rel=\"noopener\">\u5b98\u65b9\u7bc4\u4f8b GitHub<\/a>\n<\/p><\/blockquote>\n<pre><code class=\"line-numbers\">git clone https:\/\/github.com\/line\/line-bot-sdk-nodejs.git\n<\/code><\/pre>\n<h3>4. \u79fb\u52d5\u5230 echo-bot \u76ee\u9304<\/h3>\n<p>\u89e3\u58d3\u7e2e\u60a8\u525b\u525b\u4e0b\u8f09\u7684\u7bc4\u4f8b\u6a94\u6848\uff0c\u7136\u5f8c\u5728\u7d42\u7aef\u6a5f\u4e2d\u9032\u5165 echo-bot \u76ee\u9304\uff1a<\/p>\n<pre><code class=\"line-numbers\">cd line-bot-sdk-nodejs\/examples\/echo-bot\n<\/code><\/pre>\n<ul>\n<li>\u5b89\u88dd\u6240\u9700\u7684 npm \u5957\u4ef6\uff1a<\/li>\n<\/ul>\n<pre><code class=\"line-numbers\">npm install\n<\/code><\/pre>\n<h3>5. \u8907\u88fd Channel Secret<\/h3>\n<p>\u767b\u5165 <a href=\"https:\/\/developers.line.biz\/\" target=\"_blank\" rel=\"noopener\">LINE Developers<\/a>\uff0c\u5728 Basic settings \u4e2d\u627e\u5230\u4e26\u8907\u88fd\u60a8\u7684 Channel Secret\u3002<\/p>\n<p><a href=\"https:\/\/badgameshow.com\/steven\/wp-content\/uploads\/2020\/07\/wp_editor_md_4336817fdd7157fd72519f7dd5be06c2.jpg\"><img decoding=\"async\" src=\"https:\/\/badgameshow.com\/steven\/wp-content\/uploads\/2020\/07\/wp_editor_md_4336817fdd7157fd72519f7dd5be06c2.jpg\" alt=\"Channel Secret\" title=\"\"><\/a><\/p>\n<ul>\n<li>\u8a2d\u7f6e\u5168\u57df\u8b8a\u6578 CHANNEL_SECRET\uff1a<\/li>\n<\/ul>\n<pre><code class=\"line-numbers\">export CHANNEL_SECRET=\u4f60\u7684\u91d1\u9470\n<\/code><\/pre>\n<h3>6. \u8907\u88fd Channel Access Token<\/h3>\n<p>\u5728 Messaging API \u9801\u9762\u4e2d\u627e\u5230\u4e26\u8907\u88fd\u60a8\u7684 Channel Access Token\u3002<\/p>\n<p><a href=\"https:\/\/badgameshow.com\/steven\/wp-content\/uploads\/2020\/07\/wp_editor_md_8b9afc6c6ef400553b8ce0ee12d8ed5f.jpg\"><img decoding=\"async\" src=\"https:\/\/badgameshow.com\/steven\/wp-content\/uploads\/2020\/07\/wp_editor_md_8b9afc6c6ef400553b8ce0ee12d8ed5f.jpg\" alt=\"Channel Access Token\" title=\"\"><\/a><\/p>\n<ul>\n<li>\u8a2d\u7f6e\u5168\u57df\u8b8a\u6578 CHANNEL_ACCESS_TOKEN\uff1a<\/li>\n<\/ul>\n<pre><code class=\"line-numbers\">export CHANNEL_ACCESS_TOKEN=\u4f60\u7684token\n<\/code><\/pre>\n<h3>7. \u8a2d\u5b9a\u4f3a\u670d\u5668\u7684\u57e0\u865f<\/h3>\n<p>\u60a8\u53ef\u4ee5\u96a8\u610f\u8a2d\u5b9a\u57e0\u865f\uff0c\u4f8b\u5982\uff1a<\/p>\n<pre><code class=\"line-numbers\">export PORT=9999\n<\/code><\/pre>\n<h3>8. \u555f\u52d5\u4f3a\u670d\u5668<\/h3>\n<p>\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u555f\u52d5\u60a8\u7684\u4f3a\u670d\u5668\uff1a<\/p>\n<pre><code class=\"line-numbers\">npm start\n<\/code><\/pre>\n<p><a href=\"https:\/\/badgameshow.com\/steven\/wp-content\/uploads\/2020\/07\/wp_editor_md_1bc38ba794efcb32c9f1d2791acaf5d8.jpg\"><img decoding=\"async\" src=\"https:\/\/badgameshow.com\/steven\/wp-content\/uploads\/2020\/07\/wp_editor_md_1bc38ba794efcb32c9f1d2791acaf5d8.jpg\" alt=\"\u555f\u52d5\u4f3a\u670d\u5668\" title=\"\"><\/a><\/p>\n<h3>9. \u958b\u555f\u53e6\u4e00\u500b\u7d42\u7aef\u6a5f\u4e26\u555f\u52d5 ngrok<\/h3>\n<p>\u5728\u53e6\u4e00\u500b\u7d42\u7aef\u6a5f\u8996\u7a97\u4e2d\u555f\u52d5 ngrok\uff0c\u4e26\u76e3\u807d\u60a8\u525b\u8a2d\u7f6e\u7684\u57e0\u865f\uff1a<\/p>\n<pre><code class=\"line-numbers\">ngrok http 9999\n<\/code><\/pre>\n<p><a href=\"https:\/\/badgameshow.com\/steven\/wp-content\/uploads\/2020\/07\/wp_editor_md_5c51a34f45f959d1b54d16457ff45291.jpg\"><img decoding=\"async\" src=\"https:\/\/badgameshow.com\/steven\/wp-content\/uploads\/2020\/07\/wp_editor_md_5c51a34f45f959d1b54d16457ff45291.jpg\" alt=\"ngrok\" title=\"\"><\/a><\/p>\n<p>\u8a18\u4e0b ngrok \u8fd4\u56de\u7684 URL\uff0c\u4f8b\u5982:<\/p>\n<pre><code class=\"line-numbers\">https:\/\/a9e52ca76f57.ngrok.io\n<\/code><\/pre>\n<h3>10. \u9023\u63a5 Line Notify<\/h3>\n<p>\u8a2a\u554f <a href=\"https:\/\/notify-bot.line.me\/\" target=\"_blank\" rel=\"noopener\">Line Notify<\/a>\uff0c\u4e26\u5c07\u525b\u8a18\u4e0b\u7684 URL \u586b\u5165 <code>Callback URL<\/code> \u6b04\u4f4d\uff1a<\/p>\n<p><a href=\"https:\/\/badgameshow.com\/steven\/wp-content\/uploads\/2020\/07\/wp_editor_md_616578f7dc1eb095ff0144f8ba34206a.jpg\"><img decoding=\"async\" src=\"https:\/\/badgameshow.com\/steven\/wp-content\/uploads\/2020\/07\/wp_editor_md_616578f7dc1eb095ff0144f8ba34206a.jpg\" alt=\"Callback URL\" title=\"\"><\/a><\/p>\n<h3>11. \u88fd\u4f5c\u6388\u6b0a\u9023\u7d50<\/h3>\n<p>\u5728 Line Notify \u7684\u9801\u9762\u4e2d\uff0c\u8a18\u4e0b <code>Client ID<\/code> \u548c <code>Callback URL<\/code>\uff1a<\/p>\n<p><a href=\"https:\/\/badgameshow.com\/steven\/wp-content\/uploads\/2020\/07\/wp_editor_md_2724966d809b4b357fe5509d74e33f8f.jpg\"><img decoding=\"async\" src=\"https:\/\/badgameshow.com\/steven\/wp-content\/uploads\/2020\/07\/wp_editor_md_2724966d809b4b357fe5509d74e33f8f.jpg\" alt=\"Client ID \u548c Callback URL\" title=\"\"><\/a><\/p>\n<p>\u4f7f\u7528\u4ee5\u4e0b\u683c\u5f0f\u751f\u6210\u6388\u6b0a\u9023\u7d50\uff1a<\/p>\n<h4>\u7bc4\u4f8b<\/h4>\n<pre><code class=\"line-numbers\">https:\/\/notify-bot.line.me\/oauth\/authorize?response_type=code&scope=notify&response_mode=form_post&client_id=\u4f60\u7684ClientID&redirect_uri=\u4f60\u7684CallbackURL&state=\u96a8\u610f\u586b\u5beb\n<\/code><\/pre>\n<h3>12. \u9ede\u64ca\u9023\u7d50\u4e26\u6388\u6b0a<\/h3>\n<p>\u6388\u6b0a\u6210\u529f\u5f8c\uff0cLINE \u6703\u767c\u9001\u63a8\u64ad\u901a\u77e5\uff1a<\/p>\n<p><a href=\"https:\/\/badgameshow.com\/steven\/wp-content\/uploads\/2020\/07\/wp_editor_md_3fe9a31e76b6904eb5fcc3c0a18c9625.jpg\"><img decoding=\"async\" src=\"https:\/\/badgameshow.com\/steven\/wp-content\/uploads\/2020\/07\/wp_editor_md_3fe9a31e76b6904eb5fcc3c0a18c9625.jpg\" alt=\"\u6388\u6b0a\u6210\u529f\" title=\"\"><\/a><\/p>\n<h3>13. \u6aa2\u67e5 ngrok \u5f8c\u53f0\u7684\u56de\u50b3\u8cc7\u8a0a<\/h3>\n<p>\u6253\u958b <a href=\"http:\/\/127.0.0.1:4040\/inspect\/http\">ngrok \u7684\u5f8c\u53f0<\/a>\uff0c\u67e5\u770b\u525b\u525b\u7684\u56de\u50b3\u8cc7\u8a0a\uff1a<\/p>\n<p><a href=\"https:\/\/badgameshow.com\/steven\/wp-content\/uploads\/2020\/07\/wp_editor_md_be3ead8c6e3c72f80d41220194506ca6.jpg\"><img decoding=\"async\" src=\"https:\/\/badgameshow.com\/steven\/wp-content\/uploads\/2020\/07\/wp_editor_md_be3ead8c6e3c72f80d41220194506ca6.jpg\" alt=\"ngrok \u5f8c\u53f0\" title=\"\"><\/a><\/p>\n<h3>14. \u4f7f\u7528\u8005 Code \u8f49\u63db\u6210 Access Token<\/h3>\n<p>\u4f7f\u7528\u4ee5\u4e0b API \u5c07\u4f7f\u7528\u8005\u7684 code \u8f49\u63db\u70ba access_token\uff1a<\/p>\n<pre><code class=\"line-numbers\">https:\/\/notify-bot.line.me\/oauth\/token\n<\/code><\/pre>\n<p>\u8acb\u6c42\u53c3\u6578\u5305\u62ec\uff1a<\/p>\n<ul>\n<li>grant_type=authorization_code<\/li>\n<li>redirect_uri=\u4f60\u7684Callback\u9023\u7d50<\/li>\n<li>client_id=\u4f60\u7684ID<\/li>\n<li>client_secret=LINE Notify \u986f\u793a\u7684 client_secret<\/li>\n<li>code=\u525b\u525b\u4f7f\u7528\u8005\u7684\u56de\u50b3\u4ee3\u78bc<\/li>\n<\/ul>\n<p><a href=\"https:\/\/badgameshow.com\/steven\/wp-content\/uploads\/2020\/07\/wp_editor_md_0278043164816ad6fd33bc52a19493e9.jpg\"><img decoding=\"async\" src=\"https:\/\/badgameshow.com\/steven\/wp-content\/uploads\/2020\/07\/wp_editor_md_0278043164816ad6fd33bc52a19493e9.jpg\" alt=\"Access Token\" title=\"\"><\/a><\/p>\n<h3>15. \u4f7f\u7528 Access Token \u63a8\u64ad\u8a0a\u606f<\/h3>\n<p>\u73fe\u5728\u60a8\u5df2\u7d93\u64c1\u6709 access_token\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u5b83\u4f86\u900f\u904e LINE Notify \u767c\u9001\u63a8\u64ad\u8a0a\u606f\u3002\u66f4\u591a\u8a73\u7d30\u8cc7\u8a0a\uff0c\u8acb\u53c3\u8003\u6211\u4e4b\u524d\u7684\u6587\u7ae0\u3002<\/p>\n<p><a href=\"https:\/\/badgameshow.com\/steven\/wp-content\/uploads\/2020\/07\/wp_editor_md_a2b5d84a419f8936e5ebdfb5d7c04f2e.jpg\"><img decoding=\"async\" src=\"https:\/\/badgameshow.com\/steven\/wp-content\/uploads\/2020\/07\/wp_editor_md_a2b5d84a419f8936e5ebdfb5d7c04f2e.jpg\" alt=\"\u63a8\u64ad\u7bc4\u4f8b\" title=\"\"><\/a><\/p>\n<div style=\"font-family: 'times new roman'; text-align: left;\">\n<span style=\"font-size: x-large;\"><b style=\"background-color: white;\">\u66f4\u591a Line \u6280\u8853\u6587\u7ae0<\/b><\/span>\n<\/div>\n<p><span style=\"font-family: times new roman; font-size: large;\"><br \/>\n<a href=\"https:\/\/badgameshow.com\/steven\/line\/\u6559\u5b78-line-notify-\u63a8\u64ad\u4e0d\u6c42\u4eba-\u7bc4\u4f8b-python\/\" target=\"_blank\" rel=\"noopener\">[\u6559\u5b78] Line Notify \u63a8\u64ad\u4e0d\u6c42\u4eba &#8211; \u7bc4\u4f8b (Python, PHP, PostMan)<\/a><br \/>\n<\/span><br \/>\n<span style=\"font-family: times new roman; font-size: large;\"><br \/>\n<a href=\"https:\/\/badgameshow.com\/steven\/line\/line-bot-\u9023\u52d5-line-notify-mac\u5b89\u88dd\/\" target=\"_blank\" rel=\"noopener\">Line Bot \u9023\u52d5 Line Notify (Mac\u5b89\u88dd)<\/a><br \/>\n<\/span><br \/>\n<span style=\"font-family: times new roman; font-size: large;\"><br \/>\n<a href=\"https:\/\/badgameshow.com\/steven\/line\/line-bot-\u6559\u5b78\/\" target=\"_blank\" rel=\"noopener\">[\u6559\u5b78] Line Bot \u6a5f\u5668\u4eba\u4e0d\u6c42\u4eba &#8211; \u7bc4\u4f8b (Python)<\/a><br \/>\n<\/span><\/p>\n<hr \/>\n<p><a href=\"https:\/\/p.ecpay.com.tw\/99527\" target=\"_blank\" rel=\"noopener\"><img decoding=\"async\" src=\"https:\/\/badgameshow.com\/steven\/wp-content\/uploads\/2020\/11\/cup-1-1.png\" alt=\"\" title=\"\"><\/a><br \/>\n&#8212;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>response_type = code<br \/>\nresponse_mode = form_post<br \/>\nclient_id = \u4f60\u7684ID<br \/>\nredirect_uri = \u4f60\u7684callBack\u9023\u7d50<br \/>\nstate=\u96a8\u610f\u586b\u5beb Line\u6703\u4f7f\u7528\u9019\u500b\u76f4\u4e0b\u53bbHash\u52a0\u5bc6<\/p>\n","protected":false},"author":1,"featured_media":559,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[10],"tags":[11,12,13,14],"class_list":["post-127","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-line","tag-line-bot","tag-line-notify","tag-mac","tag-14"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/badgameshow.com\/steven\/wp-content\/uploads\/2020\/11\/cup-1-1.png","jetpack-related-posts":[],"jetpack_shortlink":"https:\/\/wp.me\/pcFK27-23","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/127","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/comments?post=127"}],"version-history":[{"count":10,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/127\/revisions"}],"predecessor-version":[{"id":1104,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/127\/revisions\/1104"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/media\/559"}],"wp:attachment":[{"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/media?parent=127"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/categories?post=127"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/tags?post=127"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}