{"id":122,"date":"2025-06-03T13:04:35","date_gmt":"2025-06-04T05:56:34","guid":{"rendered":"https:\/\/badgameshow.com\/steven\/?p=122"},"modified":"2025-06-04T13:04:35","modified_gmt":"2025-06-04T05:56:34","slug":"%e6%95%99%e5%ad%b8-line-notify-%e6%8e%a8%e6%92%ad%e4%b8%8d%e6%b1%82%e4%ba%ba-%e7%af%84%e4%be%8b-python","status":"publish","type":"post","link":"https:\/\/badgameshow.com\/steven\/line\/%e6%95%99%e5%ad%b8-line-notify-%e6%8e%a8%e6%92%ad%e4%b8%8d%e6%b1%82%e4%ba%ba-%e7%af%84%e4%be%8b-python\/","title":{"rendered":"\u3010\u65b0\u624b\u5fc5\u770b\u3011\u4f7f\u7528 Python\u3001PHP \u548c Postman \u5feb\u901f\u5be6\u73fe Line Notify \u63a8\u64ad\u901a\u77e5\u7684\u5b8c\u6574\u6559\u5b78"},"content":{"rendered":"<p>&#8220;`html<\/p>\n<h1>\u4f7f\u7528 Python\u3001PHP \u548c Postman \u5be6\u73fe Line Notify \u63a8\u64ad\u901a\u77e5<\/h1>\n<p><!-- \u522a\u9664\u76ee\u9304 --><\/p>\n<h2>Line Notify \u4ecb\u7d39<\/h2>\n<p>LINE Notify \u662f\u4e00\u500b\u5f37\u5927\u7684 API\uff0c\u8b93\u4f60\u80fd\u5920\u8f15\u9b06\u5730\u5c07\u8a0a\u606f\u767c\u9001\u5230 LINE\u3002\u901a\u904e\u4f7f\u7528\u4f60\u7684 <span style=\"color: orange;\">\u500b\u4eba\u5b58\u53d6\u6b0a\u6756<\/span>\uff0c\u4f60\u53ef\u4ee5\u767c\u9001 HTTP POST \u8acb\u6c42\u5230 API \u7aef\u9ede\u3002\u672c\u6587\u5c07\u8a73\u7d30\u4ecb\u7d39\u5982\u4f55\u4f7f\u7528 Python\u3001PHP \u548c Postman \u7b49\u5de5\u5177\u4f86\u5b8c\u6210\u8a0a\u606f\u767c\u9001\uff0c\u8b93\u4f60\u7684\u61c9\u7528\u7a0b\u5f0f\u900f\u904e LINE \u9032\u884c\u5373\u6642\u901a\u77e5\u3002<\/p>\n<p>\u9019\u500b\u904e\u7a0b\u80fd\u5920\u5927\u5e45\u7c21\u5316\u884c\u92b7\u548c\u8a0a\u606f\u50b3\u9054\u7684\u6d41\u7a0b\uff0c\u4e26\u900f\u904e Line Bot \u9032\u884c\u5ba2\u88fd\u5316\u7684\u529f\u80fd\u4e32\u63a5\uff0c\u70ba\u4f7f\u7528\u8005\u63d0\u4f9b\u66f4\u4f73\u7684\u9ad4\u9a57\u3002\u4f8b\u5982\uff0c\u4f7f\u7528 <span style=\"color: orange;\">Ptt Alertor<\/span> \u5c31\u80fd\u8f15\u9b06\u5be6\u73fe Line Bot \u8207 Line Notify \u7684\u9023\u52d5\u3002<\/p>\n<h3>Line Bot \u8a2d\u7f6e<\/h3>\n<p><img decoding=\"async\" src=\"https:\/\/free.com.tw\/blog\/wp-content\/uploads\/2017\/07\/Ptt-Alertorptt-alertor-05.png\" alt=\"Line Bot \u8a2d\u7f6e\" title=\"\"><br \/>\n<\/p>\n<h3>Line Notify \u63a8\u64ad<\/h3>\n<p><img decoding=\"async\" src=\"https:\/\/free.com.tw\/blog\/wp-content\/uploads\/2017\/07\/Ptt-Alertorptt-alertor-06.png\" alt=\"Line Notify \u63a8\u64ad\" title=\"\"><br \/>\n<\/p>\n<p>\u66f4\u591a Ptt Alertor \u8a73\u7d30\u4ecb\u7d39\u53ef\u9ede\u64ca\u4e0b\u65b9\u9023\u7d50:<\/p>\n<p><a class=\"wp-editor-md-post-content-link\" href=\"https:\/\/free.com.tw\/ptt-alertor\/\" title=\"Ptt Alertor \u5728 LINE\u3001\u81c9\u66f8\u63a5\u6536\u6279\u8e22\u8e22\u65b0\u6587\u7ae0\u901a\u77e5\uff0c\u53ef\u8ffd\u8e64\u4e3b\u984c\u3001\u4f5c\u8005\u548c\u63a8\u6587\" target=\"_blank\" rel=\"noopener\">Ptt Alertor \u5728 LINE\u3001\u81c9\u66f8\u63a5\u6536\u6279\u8e22\u8e22\u65b0\u6587\u7ae0\u901a\u77e5\uff0c\u53ef\u8ffd\u8e64\u4e3b\u984c\u3001\u4f5c\u8005\u548c\u63a8\u6587<\/a><\/p>\n<p>\u7c21\u55ae\u8a2d\u7f6e Line Bot \u7684\u76f8\u95dc\u6559\u5b78\u53ef\u53c3\u8003\u9019\u7bc7\u6587\u7ae0:<\/p>\n<p><a class=\"wp-editor-md-post-content-link\" href=\"https:\/\/badgameshow.com\/steven\/line\/line-bot-%e6%95%99%e5%ad%b8\/\" title=\"[\u6559\u5b78] Line Bot \u6a5f\u5668\u4eba\u4e0d\u6c42\u4eba \u2013 \u7bc4\u4f8b (Python)\">[\u6559\u5b78] Line Bot \u6a5f\u5668\u4eba\u4e0d\u6c42\u4eba \u2013 \u7bc4\u4f8b (Python)<\/a><\/p>\n<h2>Line Notify \u6b0a\u9650\u7533\u8acb\u6b65\u9a5f<\/h2>\n<h3>1. \u767b\u5165 Line Notify \u5b98\u7db2<\/h3>\n<p>\u524d\u5f80 Line Notify \u5b98\u65b9\u7db2\u7ad9\u4e26\u767b\u5165\u4f60\u7684\u5e33\u865f\u3002<\/p>\n<blockquote>\n<p><a class=\"wp-editor-md-post-content-link\" href=\"https:\/\/notify-bot.line.me\/my\/\" title=\"Line Notify \u5b98\u7db2\" target=\"_blank\" rel=\"noopener\">Line Notify \u5b98\u7db2<\/a><\/p>\n<\/blockquote>\n<h3>2. \u767c\u884c Line Notify \u6b0a\u6756<\/h3>\n<p>\u9ede\u64ca\u7db2\u9801\u5e95\u90e8\u7684 &#8220;\u767c\u884c\u6b0a\u6756&#8221; \u6309\u9215\u4ee5\u5275\u5efa\u65b0\u7684\u6b0a\u6756\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/badgameshow.com\/steven\/wp-content\/uploads\/2020\/07\/wp_editor_md_d60c011390cce78e93629415d85c3653.jpg\" width=\"50%\" alt=\"\u767c\u884c Line Notify \u6b0a\u6756\" title=\"\u767c\u884c Line Notify \u6b0a\u6756\"><\/p>\n<h3>3. \u9078\u64c7\u8981\u9023\u52d5\u7684 Line \u7fa4\u7d44<\/h3>\n<p>\u9078\u64c7\u4f60\u60f3\u8981\u8b93 Line Notify \u9023\u52d5\u7684\u7fa4\u7d44\uff0c\u4e26\u53ef\u4ee5\u4fee\u6539 Line Notify \u7684\u540d\u7a31\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/badgameshow.com\/steven\/wp-content\/uploads\/2020\/07\/wp_editor_md_a624dee3c6e2489fdab46d84c660a41b.jpg\" width=\"50%\" alt=\"\u9078\u64c7 Line Notify \u8981\u9023\u52d5\u7684\u7fa4\u7d44\" title=\"\u9078\u64c7 Line Notify \u8981\u9023\u52d5\u7684\u7fa4\u7d44\"><\/p>\n<h3>4. \u53d6\u5f97 Line Notify Token<\/h3>\n<p>\u767c\u884c\u5f8c\u6703\u986f\u793a\u4f60\u7684 <code>Line Notify token<\/code>\uff0c\u8acb\u52d9\u5fc5\u8a18\u4f4f\u9019\u500b Token\uff0c\u56e0\u70ba\u5b83\u53ea\u6703\u986f\u793a\u4e00\u6b21\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/badgameshow.com\/steven\/wp-content\/uploads\/2021\/01\/wp_editor_md_91c34deac200dda299211b480aae4fff.jpg\" width=\"50%\" alt=\"\u53d6\u5f97 Line Notify Token\" title=\"\u53d6\u5f97 Line Notify Token\"><\/p>\n<h3>5. \u9a57\u8b49\u63a8\u64ad\u6210\u529f<\/h3>\n<p>\u7576\u4f60\u6210\u529f\u8a2d\u7f6e\u5f8c\uff0cLine Notify \u6703\u63a8\u64ad\u4e00\u689d\u6210\u529f\u7684\u8a0a\u606f\u5230\u4f60\u7684 LINE \u7fa4\u7d44\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/badgameshow.com\/steven\/wp-content\/uploads\/2021\/01\/wp_editor_md_69b9342081c5f2c354121c9fef3c1c3b.jpg\" width=\"50%\" alt=\"\u9a57\u8b49\u63a8\u64ad\u6210\u529f\" title=\"\u9a57\u8b49\u63a8\u64ad\u6210\u529f\"><\/p>\n<h3>6. \u63a7\u5236 Line Notify \u6b0a\u9650<\/h3>\n<p>\u4f60\u53ef\u4ee5\u96a8\u6642\u7ba1\u7406\u548c\u63a7\u5236\u5df2\u767c\u884c\u7684 Line Notify \u6b0a\u9650\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/badgameshow.com\/steven\/wp-content\/uploads\/2020\/07\/wp_editor_md_176cba623ded5969c97ab107db8a5cf7.jpg\" width=\"50%\" alt=\"\u63a7\u5236 Line Notify \u6b0a\u9650\" title=\"\u63a7\u5236 Line Notify \u6b0a\u9650\"><\/p>\n<hr \/>\n<h2>Line Notify \u7a0b\u5f0f\u7bc4\u4f8b<\/h2>\n<h3>Json \u683c\u5f0f\u89e3\u6790<\/h3>\n<ul>\n<li>message: \u8a0a\u606f\u5167\u5bb9<\/li>\n<li>imageThumbnail: \u7e2e\u5716 URL<\/li>\n<li>imageFullsize: \u5927\u5716 URL<\/li>\n<li>imageFile: \u5716\u7247\u6a94\u6848<\/li>\n<li>stickerPackageId: \u5167\u5efa\u8cbc\u5716\u5305\u7de8\u865f<\/li>\n<li>stickerId: \u5167\u5efa\u8cbc\u5716 ID<\/li>\n<\/ul>\n<h3>Python \u7bc4\u4f8b<\/h3>\n<pre><code class=\"language-python line-numbers\">import requests\n\ndef send_notify(token, msg, filepath=None, stickerPackageId=None, stickerId=None):\n    payload = {'message': msg}\n    headers = {\n        \"Authorization\": \"Bearer \" + token\n    }\n    if stickerPackageId and stickerId:\n        payload['stickerPackageId'] = stickerPackageId\n        payload['stickerId'] = stickerId\n\n    if filepath:\n        attachment = {'imageFile': open(filepath, 'rb')}\n        r = requests.post(\"https:\/\/notify-api.line.me\/api\/notify\", headers=headers, params=payload, files=attachment)\n    else:\n        r = requests.post(\"https:\/\/notify-api.line.me\/api\/notify\", headers=headers, params=payload)\n    return r.status_code, r.text\n\n# \u6e2c\u8a66 Line Notify\ntoken = \"\u4f60\u7684\u91d1\u9470\u653e\u9019\u88e1\"\nsend_notify(token=token, msg='\u6e2c\u8a66\u8a0a\u606f', filepath='')\n<\/code><\/pre>\n<h3>PHP \u7bc4\u4f8b<\/h3>\n<pre><code class=\"language-php line-numbers\">&lt;?php\n\n<span class=\"katex math inline\">headers = array(\n    'Content-Type: multipart\/form-data',\n    'Authorization: Bearer \u4f60\u7684\u91d1\u9470\u653e\u9019\u88e1'\n);<\/span>message = array(\n    'message' =&gt; '\u9019\u662f\u4e00\u689d\u6e2c\u8a66\u8a0a\u606f',\n    \"imageThumbnail\" =&gt; \"https:\/\/www.iloveimg.com\/img\/iloveimg\/social\/zh-Hant\/compressimage.jpg\",\n    \"imageFullsize\" =&gt; \"https:\/\/www.iloveimg.com\/img\/iloveimg\/social\/zh-Hant\/compressimage.jpg\",\n    \"imageFile\" =&gt; \"image\/index.png\",\n    \"stickerPackageId\" =&gt; 1,\n    \"stickerId\" =&gt; 2\n);\n<span class=\"katex math inline\">ch = curl_init();\ncurl_setopt(<\/span>ch , CURLOPT_URL , \"https:\/\/notify-api.line.me\/api\/notify\");\ncurl_setopt(<span class=\"katex math inline\">ch, CURLOPT_HTTPHEADER,<\/span>headers);\ncurl_setopt(<span class=\"katex math inline\">ch, CURLOPT_POST, true);\ncurl_setopt(<\/span>ch, CURLOPT_POSTFIELDS, <span class=\"katex math inline\">message);<\/span>result = curl_exec(<span class=\"katex math inline\">ch);\ncurl_close(<\/span>ch);\n?&gt;<\/code><\/pre>\n<h3>Postman \u7bc4\u4f8b<\/h3>\n<p><img decoding=\"async\" src=\"https:\/\/badgameshow.com\/steven\/wp-content\/uploads\/2020\/07\/wp_editor_md_720cb50fc4bab5fc33f86b3f0a75ee43.jpg\" width=\"80%\" alt=\"Postman \u7bc4\u4f8b\" title=\"Postman \u7bc4\u4f8b\"><br \/>\n<img decoding=\"async\" src=\"https:\/\/badgameshow.com\/steven\/wp-content\/uploads\/2020\/07\/wp_editor_md_4d4404c0dc64cfb3c06e16c51d2f029e.jpg\" width=\"80%\" alt=\"Postman \u7bc4\u4f8b\" title=\"Postman \u7bc4\u4f8b\"><\/p>\n<p>LINE Notify \u662f\u4e00\u500b\u7c21\u55ae\u800c\u6709\u6548\u7684 API\uff0c\u53ef\u4ee5\u8f15\u9b06\u5730\u5c07\u8a0a\u606f\u63a8\u9001\u5230 LINE\u3002\u672c\u6587\u63d0\u4f9b\u4e86\u4f7f\u7528 Python\u3001PHP \u548c Postman \u7684\u5b8c\u6574\u7bc4\u4f8b\uff0c\u8b93\u4f60\u80fd\u5920\u5feb\u901f\u4e0a\u624b\u4e26\u5be6\u73fe\u5373\u6642\u901a\u77e5\u3002\u82e5\u60f3\u6df1\u5165\u4e86\u89e3 LINE Notify \u7684\u66f4\u591a\u529f\u80fd\uff0c\u8acb\u53c3\u8003\u5b8c\u6574\u7684\u6559\u5b78\u6587\u7ae0\u3002<\/p>\n<div style=\"font-family: 'Times New Roman'; text-align: left;\">\n    <span style=\"font-size: x-large;\"><br \/>\n        <b style=\"background-color: white;\">\u66f4\u591a LINE \u6280\u8853\u6587\u7ae0<\/b><br \/>\n    <\/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\">[\u5b8c\u6574\u6307\u5357] \u5982\u4f55\u4f7f\u7528 Python\u3001PHP \u548c Postman \u5feb\u901f\u5be6\u73fe Line Notify \u63a8\u64ad\u901a\u77e5<\/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 class=\"wp-editor-md-post-content-link\" href=\"https:\/\/p.ecpay.com.tw\/99527\" target=\"_blank\" rel=\"noopener\"><br \/>\n    <img decoding=\"async\" src=\"https:\/\/badgameshow.com\/steven\/wp-content\/uploads\/2020\/11\/cup-1-1.png\" alt=\"Line Notify\" title=\"\"><br \/>\n<\/a><br \/>\n&#8220;`<br \/>\n&#8212;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>&#8211; message \u8a0a\u606f<br \/>\n&#8211; imageThumbnail \u7e2e\u5716<br \/>\n&#8211; imageFullsize \u5927\u5716<br \/>\n&#8211; imageFile \u5716\u7247\u6a94\u6848<br \/>\n&#8211; stickerPackageId \u5167\u5efa\u8cbc\u5716\u7de8\u865f<br \/>\n&#8211; stickerId \u5167\u5efa\u8cbc\u5716\u7de8\u865f\u5167\u7684id<\/p>\n","protected":false},"author":1,"featured_media":559,"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":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[10],"tags":[12,16,17,15],"class_list":["post-122","post","type-post","status-publish","format-aside","has-post-thumbnail","hentry","category-line","tag-line-notify","tag-php","tag-postman","tag-python","post_format-post-format-aside"],"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-1Y","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/122","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=122"}],"version-history":[{"count":29,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/122\/revisions"}],"predecessor-version":[{"id":1274,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/122\/revisions\/1274"}],"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=122"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/categories?post=122"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/tags?post=122"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}