{"id":1084,"date":"2025-05-31T14:09:00","date_gmt":"2025-06-04T06:47:59","guid":{"rendered":"https:\/\/badgameshow.com\/steven\/?p=1084"},"modified":"2025-06-04T14:09:00","modified_gmt":"2025-06-04T06:47:59","slug":"line-notify-%e6%8e%88%e6%ac%8a","status":"publish","type":"post","link":"https:\/\/badgameshow.com\/steven\/python\/line-notify-%e6%8e%88%e6%ac%8a\/","title":{"rendered":"\u5982\u4f55\u5728 2025 \u5e74\u4f7f\u7528 Python \u7372\u53d6 Line Notify \u6388\u6b0a &#8211; \u5b8c\u6574\u6307\u5357 \ud83e\udd96"},"content":{"rendered":"<p>&#8220;`html<\/p>\n<h1>\u5982\u4f55\u5728 2025 \u5e74\u4f7f\u7528 Python \u7372\u53d6 Line Notify \u6388\u6b0a &#8211; \u5b8c\u6574\u6307\u5357 \ud83e\udd96<\/h1>\n<h2>\u7c21\u4ecb<\/h2>\n<p><font color=\"orange\">Line Notify \u600e\u9ebc\u6388\u6b0a?<\/font><br \/>\n\u4f7f\u7528\u8005\u5728\u4f7f\u7528 Line Bot \u6642\u82e5\u9700 Line Notify \u529f\u80fd\uff0c\u624b\u52d5\u6dfb\u52a0\u5ba2\u670d\u53ef\u80fd\u6703\u592a\u9ebb\u7169\u3002\u900f\u904e\u4e00\u689d\u9023\u7d50\u53ef\u4ee5\u76f4\u63a5\u9054\u6210 <font color=\"orange\">Line Bot \u8207 Line Notify \u7684\u9023\u52d5\u6548\u679c<\/font>\u3002\u672c\u7bc7\u6587\u7ae0\u5c07\u63d0\u4f9b Python \u7684\u7bc4\u4f8b\uff0c\u4e26\u8b1b\u89e3\u5b8c\u6574\u6d41\u7a0b\u3002<\/p>\n<h2>\u4e00\u3001Line Notify \u7533\u8acb<\/h2>\n<h3>1. \u81f3 Line Notify \u5b98\u7db2\u7ba1\u7406\u767b\u5165\u670d\u52d9<\/h3>\n<p><a class=\"wp-editor-md-post-content-link\" href=\"https:\/\/notify-bot.line.me\/\" title=\"Line Notify \u5b98\u7db2\" target=\"_blank\" rel=\"noopener\">Line Notify \u5b98\u7db2<\/a><\/p>\n<h4>\u9ede\u64ca\u53f3\u4e0a\u89d2\u540d\u7a31 -> \u7ba1\u7406\u767b\u5165\u670d\u52d9<\/h4>\n<p><img decoding=\"async\" src=\"https:\/\/badgameshow.com\/steven\/wp-content\/uploads\/2021\/01\/Line-Bot\u8207Line-Notify\u9023\u52d57.png\" alt=\"Line-Bot\u8207Line-Notify\u9023\u52d5 - \u7ba1\u7406\u767b\u5165\u670d\u52d9\" title=\"\"><\/p>\n<h3>2. \u9ede\u9078\u767b\u5165\u670d\u52d9<\/h3>\n<p><img decoding=\"async\" src=\"https:\/\/badgameshow.com\/steven\/wp-content\/uploads\/2021\/01\/Line-Bot\u8207Line-Notify\u9023\u52d58.png\" alt=\"Line-Bot\u8207Line-Notify\u9023\u52d5 - \u767b\u5165\u670d\u52d9\" title=\"\"><\/p>\n<h3>3. \u586b\u5beb Line Notify \u767b\u5165\u670d\u52d9\u57fa\u672c\u8cc7\u6599<\/h3>\n<p><img decoding=\"async\" src=\"https:\/\/badgameshow.com\/steven\/wp-content\/uploads\/2021\/01\/Line-Bot\u8207Line-Notify\u9023\u52d51.png\" alt=\"Line-Bot\u8207Line-Notify\u9023\u52d5 - \u586b\u5beb\u57fa\u672c\u8cc7\u6599\" title=\"\"><\/p>\n<h4>\u5b8c\u6210\u5f8c\u9ede\u64ca\u767b\u5165<\/h4>\n<p><img decoding=\"async\" src=\"https:\/\/badgameshow.com\/steven\/wp-content\/uploads\/2021\/01\/Line-Bot\u8207Line-Notify\u9023\u52d53.png\" alt=\"Line-Bot\u8207Line-Notify\u9023\u52d5 - \u767b\u5165\" title=\"\"><\/p>\n<h3>4. \u5b8c\u6210\u96fb\u5b50\u90f5\u4ef6\u8a8d\u8b49<\/h3>\n<p><img decoding=\"async\" src=\"https:\/\/badgameshow.com\/steven\/wp-content\/uploads\/2021\/01\/Line-Bot\u8207Line-Notify\u9023\u52d54.png\" alt=\"Line-Bot\u8207Line-Notify\u9023\u52d5 - \u5b8c\u6210\u96fb\u5b50\u90f5\u4ef6\u8a8d\u8b49\" title=\"\"><br \/>\n<img decoding=\"async\" src=\"https:\/\/badgameshow.com\/steven\/wp-content\/uploads\/2021\/01\/Line-Bot\u8207Line-Notify\u9023\u52d55.png\" alt=\"Line-Bot\u8207Line-Notify\u9023\u52d5 - \u8a8d\u8b49\u904e\u7a0b\" title=\"\"><\/p>\n<h3>5. \u7372\u53d6 Line Notify client id<\/h3>\n<p><img decoding=\"async\" src=\"https:\/\/badgameshow.com\/steven\/wp-content\/uploads\/2021\/01\/Line-Bot\u8207Line-Notify\u9023\u52d56.png\" alt=\"Line-Bot\u8207Line-Notify\u9023\u52d5 - \u7372\u53d6 client id\" title=\"\"><\/p>\n<h2>\u4e8c\u3001\u88fd\u4f5c Line Notify \u9ede\u64ca\u6388\u6b0a\u7db2\u5740<\/h2>\n<h3>authorize API \u53c3\u6578<\/h3>\n<p><a class=\"wp-editor-md-post-content-link\" href=\"https:\/\/notify-bot.line.me\/doc\/en\/\" title=\"LINE Notify API Document \u5b98\u65b9\u6587\u4ef6\" target=\"_blank\" rel=\"noopener\">LINE Notify API Document \u5b98\u65b9\u6587\u4ef6<\/a><\/p>\n<p>API \u7db2\u5740 : <code>https:\/\/notify-bot.line.me\/oauth\/authorize<\/code><\/p>\n<ul>\n<li>response_type : \u8a2d\u7f6e\u70ba code<\/li>\n<li>scope : \u8a2d\u7f6e\u70ba notify<\/li>\n<li>response_mode : \u8a2d\u7f6e\u70ba form_post<\/li>\n<li>client_id : \u4f60\u7533\u8acb\u7684 client_id<\/li>\n<li>redirect_uri : Call Back \u7db2\u5740<\/li>\n<li>state : \u7528\u65bc\u907f\u514d CSRF \u653b\u64ca\u7684\u53c3\u6578<\/li>\n<\/ul>\n<h4>API \u53c3\u6578\u7bc4\u4f8b<\/h4>\n<pre><code class=\"language-php line-numbers\">https:\/\/notify-bot.line.me\/oauth\/authorize?response_type=code&scope=notify&response_mode=form_post&client_id=wH9GbY6s&redirect_uri=https:\/\/badgameshow.com\/laichao\/test\/push_test.php&state=123\n<\/code><\/pre>\n<h3>\u7db2\u5740\u9ede\u64ca\u6548\u679c<\/h3>\n<p><img decoding=\"async\" src=\"https:\/\/badgameshow.com\/steven\/wp-content\/uploads\/2021\/01\/IMG_0368-473x1024.png\" alt=\"Line-Bot\u8207Line-Notify\u9023\u52d5 - \u9ede\u64ca\u6548\u679c\" title=\"\"><\/p>\n<h2>\u4e09\u3001\u6388\u6b0a\u5b8c\u6210 Call back \u7db2\u5740\u88fd\u4f5c<\/h2>\n<p>\u525b\u525b\u6388\u6b0a\u5b8c\u7562\u5f8c\u6703\u547c\u53eb redirect_uri\uff0c\u9019\u88e1\u4f7f\u7528 Python \u4f86\u505a\u7bc4\u4f8b\u3002<\/p>\n<h3>Line Notify \u53d6\u5f97 access_token API<\/h3>\n<p><img decoding=\"async\" src=\"https:\/\/badgameshow.com\/steven\/wp-content\/uploads\/2021\/01\/Line-Bot\u8207Line-Notify\u9023\u52d59.png\" alt=\"Line-Bot\u8207Line-Notify\u9023\u52d5 - \u53d6\u5f97 access_token\" title=\"\"><br \/>\n<img decoding=\"async\" src=\"https:\/\/badgameshow.com\/steven\/wp-content\/uploads\/2021\/01\/Line-Bot\u8207Line-Notify\u9023\u52d510.png\" alt=\"Line-Bot\u8207Line-Notify\u9023\u52d5 - access_token\" title=\"\"><\/p>\n<p>API \u7db2\u5740 : <code>https:\/\/notify-bot.line.me\/oauth\/token<\/code><\/p>\n<ul>\n<li>grant_type : \u56fa\u5b9a\u53c3\u6578\u70ba authorization_code<\/li>\n<li>redirect_uri : Call Back \u7db2\u5740<\/li>\n<li>client_id : \u525b\u525b\u7533\u8acb\u7684 Line Notify client_id<\/li>\n<li>client_secret : \u525b\u525b\u7533\u8acb\u7684 Line Notify client_secret<\/li>\n<li>code : $_POST[&#8220;code&#8221;] Call Back \u56de\u4f86\u7684\u8cc7\u6599<\/li>\n<\/ul>\n<p>\u547c\u53eb\u5f8c\u53ef\u4ee5\u53d6\u5f97 Line Notify \u4f7f\u7528\u7684\u63a8\u64ad access_token\u3002<\/p>\n<h3>Line Notify \u63a8\u64ad API<\/h3>\n<p>API \u7db2\u5740 : <code>https:\/\/notify-api.line.me\/api\/notify<\/code><\/p>\n<ul>\n<li>message : \u4f60\u8981\u50b3\u9001\u7684\u6587\u5b57<\/li>\n<li>Header \u8a18\u5f97\u653e Bearer + access_token<\/li>\n<\/ul>\n<h3>Line Notify Python \u7bc4\u4f8b<\/h3>\n<pre><code class=\"language-python line-numbers\">import requests\n\ndef get_access_token(client_id, client_secret, code, redirect_uri):\n    url = \"https:\/\/notify-bot.line.me\/oauth\/token\"\n    data = {\n        'grant_type': 'authorization_code',\n        'redirect_uri': redirect_uri,\n        'client_id': client_id,\n        'client_secret': client_secret,\n        'code': code\n    }\n    response = requests.post(url, data=data)\n    return response.json().get('access_token')\n\ndef send_notification(access_token, message):\n    url = \"https:\/\/notify-api.line.me\/api\/notify\"\n    headers = {\"Authorization\": f\"Bearer {access_token}\"}\n    data = {\"message\": message}\n    response = requests.post(url, headers=headers, data=data)\n    return response.status_code\n\n# \u4f7f\u7528\u7bc4\u4f8b\nclient_id = \"wH9GM69ySuHI4PIZEPbY6s\"\nclient_secret = \"klv0d7IZdIKb19Xb0ujKMnoWd15xwW3rYb2Hna3Plwh\"\ncode = \"\u4f60\u7684\u56de\u50b3\u4ee3\u78bc\"\nredirect_uri = \"https:\/\/badgameshow.com\/laichao\/test\/push_test.php\"\n\naccess_token = get_access_token(client_id, client_secret, code, redirect_uri)\nsend_notification(access_token, \"\u63a8\u64ad\u7d81\u5b9a\u6210\u529f\")\n<\/code><\/pre>\n<h2>\u56db\u3001\u5b8c\u6210\u6548\u679c<\/h2>\n<p><a class=\"wp-editor-md-post-content-link\" href=\"https:\/\/badgameshow.com\/steven\/wp-content\/uploads\/2021\/01\/wp_editor_md_59910d7f9cbdd1ad674e3392c5bd059d.jpg\"><img decoding=\"async\" src=\"https:\/\/badgameshow.com\/steven\/wp-content\/uploads\/2021\/01\/wp_editor_md_59910d7f9cbdd1ad674e3392c5bd059d.jpg\" alt=\"Line-Bot\u8207Line-Notify\u9023\u52d5 - \u5b8c\u6210\u6548\u679c\" title=\"\"><\/a><\/p>\n<div style=\"font-family: times new roman; text-align: left;\"><span style=\"font-size: x-large;\"><b style=\"background-color: white;\">\u66f4\u591a Line \u6280\u8853\u6587\u7ae0<\/b><\/span><\/div>\n<p><span style=\"font-family: times new roman; font-size: large;\"><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><\/span><br \/>\n<span style=\"font-family: times new roman; font-size: large;\"><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><\/span><br \/>\n<span style=\"font-family: times new roman; font-size: large;\"><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><\/span><\/p>\n<h2>Q&#038;A\uff08\u5e38\u898b\u554f\u984c\u89e3\u7b54\uff09<\/h2>\n<h3>Q1: \u5982\u4f55\u8655\u7406 Line Notify \u6388\u6b0a\u5931\u6557\u7684\u554f\u984c\uff1f<\/h3>\n<p>A1: \u8acb\u6aa2\u67e5 client_id \u548c client_secret \u662f\u5426\u6b63\u78ba\uff0c\u4e26\u78ba\u4fdd redirect_uri \u7b26\u5408 LINE Notify \u7684\u8981\u6c42\u3002<\/p>\n<h3>Q2: \u4f7f\u7528 Python \u767c\u9001\u901a\u77e5\u6642\u6709\u4ec0\u9ebc\u63d0\u793a\uff1f<\/h3>\n<p>A2: \u78ba\u4fdd\u4f7f\u7528 requests \u6a21\u7d44\u4e26\u8655\u7406\u53ef\u80fd\u7684 HTTP \u8acb\u6c42\u932f\u8aa4\uff0c\u6700\u597d\u5728\u767c\u9001\u901a\u77e5\u524d\u9032\u884c\u932f\u8aa4\u8655\u7406\u3002<\/p>\n<h3>Q3: Line Notify \u7684\u4f7f\u7528\u9650\u5236\u662f\u4ec0\u9ebc\uff1f<\/h3>\n<p>A3: \u6bcf\u500b\u61c9\u7528\u6bcf\u5929\u53ef\u767c\u9001\u7684\u8a0a\u606f\u6578\u91cf\u6709\u4e0a\u9650\uff0c\u5177\u9ad4\u53ef\u4ee5\u53c3\u8003 LINE Notify \u7684\u5b98\u65b9\u6587\u6a94\u3002<\/p>\n<p>\u5982\u9700\u9032\u4e00\u6b65\u4e86\u89e3 Python \u6280\u8853\uff0c\u8acb\u53c3\u8003\u9019\u7bc7\u6587\u7ae0\uff1a<a href=\"https:\/\/vocus.cc\/article\/605d6b1f0d4b1e001b6e5d4c\" rel=\"nofollow noopener\" target=\"_blank\">\u7528 Python \u5efa\u69cb\u4f60\u7684 LINE BOT \u804a\u5929\u6a5f\u5668\u4eba \u2014 \u90e8\u7f72\u7bc7<\/a><\/p>\n<p>&#8220;`<br \/>\n&#8212;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>&#8220;`html \u5982\u4f55\u5728 2025 \u5e74\u4f7f\u7528&#8230;<\/p>\n","protected":false},"author":1,"featured_media":1091,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"aside","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[18,10],"tags":[116,115,14],"class_list":{"0":"post-1084","1":"post","2":"type-post","3":"status-publish","4":"format-aside","5":"has-post-thumbnail","6":"hentry","7":"category-python","8":"category-line","9":"tag-line","11":"tag-14","12":"post_format-post-format-aside"},"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/badgameshow.com\/steven\/wp-content\/uploads\/2021\/01\/Line-Bot\u8207Line-Notify\u9023\u52d57.png","jetpack-related-posts":[],"jetpack_shortlink":"https:\/\/wp.me\/pcFK27-hu","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/1084","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=1084"}],"version-history":[{"count":17,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/1084\/revisions"}],"predecessor-version":[{"id":13084,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/1084\/revisions\/13084"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/media\/1091"}],"wp:attachment":[{"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/media?parent=1084"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/categories?post=1084"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/tags?post=1084"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}