{"id":657,"date":"2026-12-02T22:58:43","date_gmt":"2026-12-02T14:58:43","guid":{"rendered":"https:\/\/wp.chih-hao.synology.me\/?p=657"},"modified":"2026-12-03T02:08:43","modified_gmt":"2026-12-02T18:08:43","slug":"line-bot-%e5%9c%96%e6%96%87%e9%81%b8%e5%96%ae%e9%80%b2%e9%9a%8e%ef%bd%9c%e5%85%88%e7%b5%a6%e6%b8%ac%e8%a9%a6%e5%b8%b3%e8%99%9f%ef%bc%8c%e5%86%8d%e5%88%87%e6%8f%9b%e9%a0%90%e8%a8%ad%e8%88%87%e5%9b%9e","status":"publish","type":"post","link":"https:\/\/wp.chih-hao.synology.me\/?p=657","title":{"rendered":"LINE Bot \u5716\u6587\u9078\u55ae\u9032\u968e\uff5c\u5148\u7d66\u6e2c\u8a66\u5e33\u865f\uff0c\u518d\u5207\u63db\u9810\u8a2d\u8207\u56de\u5fa9"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">\u65b0\u7248\u5716\u6587\u9078\u55ae\u505a\u597d\u5f8c\uff0c\u53ef\u4ee5\u5148\u6307\u5b9a\u7d66\u4e00\u500b\u6e2c\u8a66\u5e33\u865f\uff0c\u7528\u624b\u6a5f\u78ba\u8a8d\u9078\u55ae\u5916\u89c0\u548c\u9ede\u64ca\u52d5\u4f5c\u3002\u78ba\u8a8d\u7121\u8aa4\u5f8c\uff0c\u518d\u5207\u6210\u5b98\u65b9\u5e33\u865f\u7684\u9810\u8a2d\u9078\u55ae\u3002\u958b\u59cb\u524d\u5148\u8a18\u4e0b\u539f\u672c\u7684\u9810\u8a2d ID\uff0c\u65e5\u5f8c\u8981\u56de\u5fa9\u6642\uff0c\u5c31\u80fd\u7528\u539f\u672c\u7684\u9078\u55ae\u548c\u5716\u7247\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e0b\u9762\u6703\u7528 PowerShell 7\uff0c\u5728\u540c\u4e00\u500b Messaging API channel \u64cd\u4f5c\u5df2\u4e0a\u50b3\u5716\u7247\u7684\u9078\u55ae\u3002\u5148\u5099\u59a5\u65b0\u7248\u7684 <code>richMenuId<\/code>\uff0c\u4e26\u7531\u90e8\u7f72\u74b0\u5883\u6216\u4f60\u6163\u7528\u7684\u5bc6\u9470\u5de5\u5177\u8f09\u5165 <code>LINE_CHANNEL_ACCESS_TOKEN<\/code>\u3002\u8981\u5148\u5efa\u7acb\u9078\u55ae\u8207\u4e0a\u50b3\u5716\u7247\uff0c\u53ef\u53c3\u8003<a href=\"https:\/\/wp.chih-hao.synology.me\/?p=655\">\u5716\u6587\u9078\u55ae\u57fa\u790e\u7bc7<\/a>\u3002<\/p>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_91 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">\u6587\u7ae0\u76ee\u9304<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"\u986f\u793a\/\u96b1\u85cf\u5167\u5bb9\u76ee\u9304\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/wp.chih-hao.synology.me\/?p=657\/#%E5%85%88%E7%A2%BA%E8%AA%8D%E6%B8%AC%E8%A9%A6%E5%B8%B3%E8%99%9F%E5%92%8C%E9%81%B8%E5%96%AE%E5%B1%AC%E6%96%BC%E5%90%8C%E4%B8%80%E5%80%8B_channel\" >\u5148\u78ba\u8a8d\u6e2c\u8a66\u5e33\u865f\u548c\u9078\u55ae\u5c6c\u65bc\u540c\u4e00\u500b channel<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/wp.chih-hao.synology.me\/?p=657\/#%E7%94%A8_GET_%E7%95%99%E4%B8%8B%E5%88%87%E6%8F%9B%E5%89%8D%E7%9A%84%E7%8B%80%E6%85%8B\" >\u7528 GET \u7559\u4e0b\u5207\u63db\u524d\u7684\u72c0\u614b<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/wp.chih-hao.synology.me\/?p=657\/#%E6%8A%8A%E6%96%B0%E7%89%88%E5%8F%AA%E9%80%A3%E7%B5%90%E7%B5%A6%E6%B8%AC%E8%A9%A6%E5%B8%B3%E8%99%9F\" >\u628a\u65b0\u7248\u53ea\u9023\u7d50\u7d66\u6e2c\u8a66\u5e33\u865f<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/wp.chih-hao.synology.me\/?p=657\/#%E5%88%87%E6%88%90%E9%A0%90%E8%A8%AD%EF%BC%8C%E5%86%8D%E8%A7%A3%E9%99%A4%E6%B8%AC%E8%A9%A6%E5%B8%B3%E8%99%9F%E7%9A%84%E5%80%8B%E4%BA%BA%E9%81%B8%E5%96%AE\" >\u5207\u6210\u9810\u8a2d\uff0c\u518d\u89e3\u9664\u6e2c\u8a66\u5e33\u865f\u7684\u500b\u4eba\u9078\u55ae<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/wp.chih-hao.synology.me\/?p=657\/#%E8%A7%A3%E9%99%A4%E6%B8%AC%E8%A9%A6%E5%B8%B3%E8%99%9F%E7%9A%84%E5%80%8B%E4%BA%BA%E9%81%B8%E5%96%AE\" >\u89e3\u9664\u6e2c\u8a66\u5e33\u865f\u7684\u500b\u4eba\u9078\u55ae<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/wp.chih-hao.synology.me\/?p=657\/#%E7%94%A8%E5%BF%AB%E7%85%A7%E5%9B%9E%E5%BE%A9%E9%A0%90%E8%A8%AD\" >\u7528\u5feb\u7167\u56de\u5fa9\u9810\u8a2d<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E5%85%88%E7%A2%BA%E8%AA%8D%E6%B8%AC%E8%A9%A6%E5%B8%B3%E8%99%9F%E5%92%8C%E9%81%B8%E5%96%AE%E5%B1%AC%E6%96%BC%E5%90%8C%E4%B8%80%E5%80%8B_channel\"><\/span>\u5148\u78ba\u8a8d\u6e2c\u8a66\u5e33\u865f\u548c\u9078\u55ae\u5c6c\u65bc\u540c\u4e00\u500b channel<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u7528\u81ea\u5df1\u7684\u6e2c\u8a66\u5e33\u865f\u5728\u624b\u6a5f\u4e0a\u52a0\u5165\u76ee\u6a19 LINE \u5b98\u65b9\u5e33\u865f\u3002\u53d6 ID \u6709\u5169\u500b\u65b9\u6cd5\u3002\u53ef\u4ee5\u5f9e\u5df2\u9a57\u8b49\u7c3d\u7ae0\u7684 <code>follow<\/code> Webhook \u8b80\u53d6 <code>source.userId<\/code>\u3002\u5982\u679c\u4f60\u7684 Business ID \u5df2\u9023\u7d50\u9019\u652f\u6e2c\u8a66\u7528\u7684 LINE \u5e33\u865f\uff0c\u4e5f\u53ef\u4ee5\u5230\u8a72 channel \u7684 <strong>Basic settings<\/strong> \u53d6\u5f97 <strong>Your user ID<\/strong>\u3002\u540c\u4e00\u500b\u4eba\u5728\u4e0d\u540c provider \u7684 ID \u53ef\u80fd\u4e0d\u540c\uff0c\u8acb\u78ba\u8a8d\u4f86\u6e90\u662f\u53d7\u6e2c\u7684 channel\uff0c\u4e26\u7528 <code>GET \/v2\/bot\/profile\/{userId}<\/code> \u518d\u6838\u5c0d\u4e00\u6b21\u3002\u6e2c\u8a66\u5e33\u865f\u4ecd\u9700\u5728\u624b\u6a5f\u4e0a\u5be6\u969b\u52a0\u5165\u5b98\u65b9\u5e33\u865f\u3002<a href=\"https:\/\/developers.line.biz\/en\/docs\/messaging-api\/getting-user-ids\/\" target=\"_blank\" rel=\"noopener\">LINE \u5b98\u65b9\u4f7f\u7528\u8005 ID \u8aaa\u660e<\/a>\u3001<a href=\"https:\/\/developers.line.biz\/en\/docs\/messaging-api\/verify-webhook-signature\/\" target=\"_blank\" rel=\"noopener\">Webhook \u7c3d\u7ae0\u9a57\u8b49<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5148\u5728 <code>pwsh<\/code> \u8cbc\u4e0a\u4e0b\u9762\u7684\u5171\u7528\u6307\u4ee4\u3002\u5f8c\u9762\u7684\u6b65\u9a5f\u53ef\u5728\u540c\u4e00\u500b\u8996\u7a97\u4f9d\u5e8f\u64cd\u4f5c\u3002\u7a0b\u5f0f\u6703\u8b80\u53d6\u74b0\u5883\u8b8a\u6578\uff0cAPI \u56de\u50b3\u932f\u8aa4\u6642\u6703\u986f\u793a HTTP \u72c0\u614b\u78bc\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5982\u679c\u624b\u908a\u6c92\u6709\u5bc6\u9470\u5de5\u5177\uff0cPowerShell 7.2 \u4ee5\u4e0a\u53ef\u5728\u76ee\u524d\u7684\u5de5\u4f5c\u968e\u6bb5\u7528\u906e\u853d\u8f38\u5165\u8a2d\u5b9a\u6b0a\u6756\u3002\u57f7\u884c <code>$env:LINE_CHANNEL_ACCESS_TOKEN = Read-Host '\u8cbc\u4e0a Channel access token' -MaskInput<\/code>\uff0c\u51fa\u73fe\u63d0\u793a\u5f8c\u518d\u8cbc\u4e0a\u6b0a\u6756\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>if ([string]::IsNullOrWhiteSpace($env:LINE_CHANNEL_ACCESS_TOKEN)) {\n    throw '\u8acb\u5148\u8f09\u5165 LINE_CHANNEL_ACCESS_TOKEN\u3002'\n}\n\n$headers = @{ Authorization = \"Bearer $env:LINE_CHANNEL_ACCESS_TOKEN\" }\n$defaultPath = 'user\/all\/richmenu'\n$snapshotPath = Join-Path $PWD 'line-rich-menu-rollout.json'\n\nfunction Invoke-Line($method, $path) {\n    Invoke-WebRequest -Method $method -Uri \"https:\/\/api.line.me\/v2\/bot\/$path\" `\n        -Headers $headers -SkipHttpErrorCheck -TimeoutSec 20 -ErrorAction Stop\n}\n\nfunction Assert-LineOk($response) {\n    if ([int]$response.StatusCode -ne 200) {\n        throw \"LINE API \u56de\u50b3 HTTP $($response.StatusCode)\u3002\"\n    }\n}\n\nfunction Get-LineJson($path) {\n    $response = Invoke-Line GET $path\n    Assert-LineOk $response\n    $response.Content | ConvertFrom-Json\n}\n\nfunction Get-LineMenuId($path) {\n    $response = Invoke-Line GET $path\n    if ([int]$response.StatusCode -eq 404) { return $null }\n    Assert-LineOk $response\n    $id = ($response.Content | ConvertFrom-Json).richMenuId\n    if (-not $id) { throw 'HTTP 200 \u7684\u56de\u61c9\u6c92\u6709 richMenuId\u3002' }\n    return $id\n}\n\nfunction Read-LineRollout {\n    $saved = Get-Content -LiteralPath $snapshotPath -Raw | ConvertFrom-Json\n    if ($saved.testerId -cnotmatch '^U[0-9a-f]{32}$' -or\n        $saved.candidateId -cnotmatch '^richmenu-[a-zA-Z0-9_-]+$' -or\n        ($saved.previousDefault -and\n         $saved.previousDefault -cnotmatch '^richmenu-[a-zA-Z0-9_-]+$')) {\n        throw '\u5feb\u7167\u4e2d\u7684 ID \u683c\u5f0f\u4e0d\u6b63\u78ba\u3002'\n    }\n    $bot = Get-LineJson 'info'\n    if (-not $saved.botUserId -or $bot.userId -cne $saved.botUserId) {\n        throw '\u5feb\u7167\u548c\u76ee\u524d\u6b0a\u6756\u7684\u5b98\u65b9\u5e33\u865f\u4e0d\u4e00\u81f4\u3002'\n    }\n    return $saved\n}<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E7%94%A8_GET_%E7%95%99%E4%B8%8B%E5%88%87%E6%8F%9B%E5%89%8D%E7%9A%84%E7%8B%80%E6%85%8B\"><\/span>\u7528 GET \u7559\u4e0b\u5207\u63db\u524d\u7684\u72c0\u614b<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u6838\u5c0d <code>GET \/v2\/bot\/info<\/code> \u56de\u50b3\u7684 <code>basicId<\/code> \u548c\u4f60\u9810\u8a08\u6e2c\u8a66\u7684\u5b98\u65b9\u5e33\u865f Basic ID\uff0c\u518d\u67e5\u65b0\u7248\u9078\u55ae\u8207\u6e2c\u8a66\u5e33\u865f\u3002\u5feb\u7167\u6703\u8a18\u9304\u820a\u9810\u8a2d\u3001\u65b0\u9078\u55ae\u548c\u6e2c\u8a66\u5e33\u865f ID\u3002\u628a\u5b83\u7559\u5728\u53ea\u6709\u7ba1\u7406\u8005\u80fd\u5b58\u53d6\u7684\u5de5\u4f5c\u76ee\u9304\uff0c\u820a\u9078\u55ae\u8207\u5716\u7247\u4e5f\u8981\u4fdd\u7559\u5230\u90e8\u7f72\u78ba\u8a8d\u70ba\u6b62\u3002<a href=\"https:\/\/developers.line.biz\/en\/reference\/messaging-api\/nojs\/#get-bot-info\" target=\"_blank\" rel=\"noopener\">\u67e5\u8a62\u5b98\u65b9\u5e33\u865f<\/a>\u3001<a href=\"https:\/\/developers.line.biz\/en\/reference\/messaging-api\/nojs\/#get-default-rich-menu-id\" target=\"_blank\" rel=\"noopener\">\u67e5\u8a62\u9810\u8a2d\u5716\u6587\u9078\u55ae<\/a><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$expectedBasicId = (Read-Host '\u8f38\u5165\u76ee\u6a19\u5b98\u65b9\u5e33\u865f Basic ID\uff0c\u542b @').Trim()\n$candidateId = (Read-Host '\u8f38\u5165\u65b0\u7248 richMenuId').Trim()\n$testerId = (Read-Host '\u8f38\u5165\u9019\u6b21\u6e2c\u8a66\u7528\u7684 userId').Trim()\n\nif ($candidateId -cnotmatch '^richmenu-[a-zA-Z0-9_-]+$' -or\n    $testerId -cnotmatch '^U[0-9a-f]{32}$') {\n    throw '\u8acb\u78ba\u8a8d richMenuId \u548c userId \u683c\u5f0f\u3002'\n}\nif (Test-Path -LiteralPath $snapshotPath) {\n    throw '\u6b64\u76ee\u9304\u5df2\u6709\u5feb\u7167\u3002\u8acb\u79fb\u81f3\u672c\u6b21\u64cd\u4f5c\u5c08\u7528\u7684\u65b0\u76ee\u9304\u3002'\n}\n\n$bot = Get-LineJson 'info'\nif (-not $bot.userId -or $bot.basicId -ne $expectedBasicId) {\n    throw '\u6b0a\u6756\u6307\u5411\u7684\u5b98\u65b9\u5e33\u865f\u8207\u9810\u671f\u4e0d\u7b26\u3002'\n}\n\n$menu = Get-LineJson \"richmenu\/$candidateId\"\n$profile = Get-LineJson \"profile\/$testerId\"\nif ($menu.richMenuId -cne $candidateId -or $profile.userId -cne $testerId) {\n    throw '\u9078\u55ae\u6216\u6e2c\u8a66\u5e33\u865f\u7684 ID \u7121\u6cd5\u6838\u5c0d\u3002'\n}\n\n$testerPath = \"user\/$testerId\/richmenu\"\n$previousDefault = Get-LineMenuId $defaultPath\nif ($previousDefault -ceq $candidateId) {\n    throw '\u65b0\u7248\u5df2\u662f\u9810\u8a2d\uff0c\u8acb\u78ba\u8a8d\u9019\u6b21\u8981\u6e2c\u8a66\u7684 ID\u3002'\n}\nif (Get-LineMenuId $testerPath) {\n    throw '\u9019\u652f\u5e33\u865f\u5df2\u6709\u500b\u4eba\u9078\u55ae\uff0c\u8acb\u63db\u53e6\u4e00\u652f\u6e2c\u8a66\u5e33\u865f\u3002'\n}\n\n$snapshot = [pscustomobject]@{\n    botUserId       = $bot.userId\n    candidateId     = $candidateId\n    testerId        = $testerId\n    previousDefault = $previousDefault\n}\n$snapshot | ConvertTo-Json | Set-Content -LiteralPath $snapshotPath -Encoding utf8\n'\u5df2\u5132\u5b58\u5feb\u7167\u3002'<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u67e5\u9810\u8a2d\u6642\uff0c<code>200<\/code> \u4ee3\u8868\u6709 API \u8a2d\u5b9a\u7684\u9810\u8a2d ID\u3002\u78ba\u8a8d\u662f\u6b63\u78ba\u5b98\u65b9\u5e33\u865f\u548c\u6b63\u78ba\u8def\u5f91\u5f8c\uff0c\u9019\u500b\u7aef\u9ede\u7684 <code>404<\/code> \u4ee3\u8868\u539f\u672c\u6c92\u6709\u9810\u8a2d\u3002\u5b98\u65b9\u4e5f\u5217\u51fa <code>403<\/code>\uff0c\u53ef\u80fd\u662f\u7531 LINE Official Account Manager \u7b49\u5176\u4ed6\u4f86\u6e90\u8a2d\u5b9a\uff0c\u9047\u5230\u6642\u5148\u5728\u539f\u7ba1\u7406\u4ecb\u9762\u67e5\u6e05\u695a\u3002\u67e5\u500b\u4eba\u9078\u55ae\u7684 <code>404<\/code> \u6709\u591a\u7a2e\u539f\u56e0\uff0c\u5305\u62ec\u672a\u9023\u7d50\u3001\u627e\u4e0d\u5230\u4f7f\u7528\u8005\uff0c\u6216\u6e2c\u8a66\u5e33\u865f\u9084\u6c92\u52a0\u597d\u53cb\u3002\u5148\u6838\u5c0d\u6e2c\u8a66\u624b\u6a5f\u4e0a\u7684\u597d\u53cb\u72c0\u614b\u8207\u500b\u4eba\u8cc7\u6599\u67e5\u8a62\u7d50\u679c\uff0c\u518d\u89e3\u8b80\u70ba\u6c92\u6709\u500b\u4eba\u9078\u55ae\u3002<a href=\"https:\/\/developers.line.biz\/en\/reference\/messaging-api\/nojs\/#get-default-rich-menu-id\" target=\"_blank\" rel=\"noopener\">\u9810\u8a2d\u9078\u55ae\u56de\u61c9\u898f\u683c<\/a>\u3001<a href=\"https:\/\/developers.line.biz\/en\/reference\/messaging-api\/nojs\/#get-rich-menu-id-of-user\" target=\"_blank\" rel=\"noopener\">\u500b\u4eba\u9078\u55ae\u56de\u61c9\u898f\u683c<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E6%8A%8A%E6%96%B0%E7%89%88%E5%8F%AA%E9%80%A3%E7%B5%90%E7%B5%A6%E6%B8%AC%E8%A9%A6%E5%B8%B3%E8%99%9F\"><\/span>\u628a\u65b0\u7248\u53ea\u9023\u7d50\u7d66\u6e2c\u8a66\u5e33\u865f<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u628a\u9078\u55ae\u9023\u7d50\u5230\u9019\u652f\u5e33\u865f\uff0c\u518d\u7528 GET \u67e5\u56de ID\u3002LINE \u5728\u67d0\u4e9b\u7121\u6cd5\u5be6\u969b\u9023\u7d50\u7684\u60c5\u6cc1\u4e0b\u4e5f\u6703\u56de\u50b3 <code>200<\/code>\uff0c\u6240\u4ee5\u8981\u6838\u5c0d GET \u50b3\u56de\u7684 <code>richMenuId<\/code>\uff0c\u4e26\u5728\u624b\u6a5f\u4e0a\u78ba\u8a8d\u3002\u500b\u4eba\u5716\u6587\u9078\u55ae\u6703\u512a\u5148\u65bc API \u8207 LINE Official Account Manager \u7684\u9810\u8a2d\u9078\u55ae\u3002<a href=\"https:\/\/developers.line.biz\/en\/docs\/messaging-api\/use-per-user-rich-menus\/\" target=\"_blank\" rel=\"noopener\">LINE \u5b98\u65b9\u500b\u4eba\u5716\u6587\u9078\u55ae\u6307\u5357<\/a>\u3001<a href=\"https:\/\/developers.line.biz\/en\/reference\/messaging-api\/nojs\/#link-rich-menu-to-user\" target=\"_blank\" rel=\"noopener\">\u9023\u7d50\u7aef\u9ede\u8207\u9650\u5236<\/a><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>if (Get-LineMenuId $testerPath) {\n    throw '\u6e2c\u8a66\u5e33\u865f\u76ee\u524d\u6709\u500b\u4eba\u9078\u55ae\uff0c\u8acb\u5148\u78ba\u8a8d\u72c0\u614b\u3002'\n}\nAssert-LineOk (Invoke-Line POST \"$testerPath\/$candidateId\")\nif ((Get-LineMenuId $testerPath) -cne $candidateId) {\n    throw '\u67e5\u4e0d\u5230\u9810\u671f\u7684\u500b\u4eba\u9078\u55ae\uff0c\u8acb\u6aa2\u67e5\u52a0\u597d\u53cb\u72c0\u614b\u8207\u9078\u55ae ID\u3002'\n}\n'\u6e2c\u8a66\u5e33\u865f\u5df2\u9023\u7d50\u65b0\u7248\u3002'<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u5728\u6e2c\u8a66\u624b\u6a5f\u958b\u555f\u5b98\u65b9\u5e33\u865f\u7684\u804a\u5929\u756b\u9762\uff0c\u5c55\u958b\u5716\u6587\u9078\u55ae\uff0c\u9010\u683c\u9ede\u64ca\u78ba\u8a8d\u7db2\u5740\u3001\u6587\u5b57\u6216 postback \u5c0d\u61c9\u6b63\u78ba\u3002\u82e5\u767c\u73fe\u554f\u984c\uff0c\u76f4\u63a5\u57f7\u884c\u5f8c\u9762\u7684\u300c\u89e3\u9664\u6e2c\u8a66\u5e33\u865f\u7684\u500b\u4eba\u9078\u55ae\u300d\uff0c\u4fee\u6b63\u5f8c\u518d\u6e2c\u8a66\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E5%88%87%E6%88%90%E9%A0%90%E8%A8%AD%EF%BC%8C%E5%86%8D%E8%A7%A3%E9%99%A4%E6%B8%AC%E8%A9%A6%E5%B8%B3%E8%99%9F%E7%9A%84%E5%80%8B%E4%BA%BA%E9%81%B8%E5%96%AE\"><\/span>\u5207\u6210\u9810\u8a2d\uff0c\u518d\u89e3\u9664\u6e2c\u8a66\u5e33\u865f\u7684\u500b\u4eba\u9078\u55ae<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u624b\u6a5f\u9a57\u6536\u5f8c\uff0c\u5148\u78ba\u8a8d\u9810\u8a2d\u4ecd\u8207\u5feb\u7167\u4e00\u81f4\uff0c\u518d\u5207\u63db\u3002\u9810\u8a2d\u6703\u5957\u7528\u5230\u7b26\u5408\u986f\u793a\u689d\u4ef6\u7684\u804a\u5929\u756b\u9762\u3002\u539f\u672c\u6709\u500b\u4eba\u9078\u55ae\u7684\u4f7f\u7528\u8005\u4ecd\u6703\u512a\u5148\u770b\u5230\u81ea\u5df1\u7684\u8a2d\u5b9a\u3002<a href=\"https:\/\/developers.line.biz\/en\/reference\/messaging-api\/nojs\/#set-default-rich-menu\" target=\"_blank\" rel=\"noopener\">\u8a2d\u5b9a\u9810\u8a2d\u9078\u55ae\u8207\u512a\u5148\u9806\u5e8f<\/a><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>if ((Get-LineMenuId $defaultPath) -cne $snapshot.previousDefault) {\n    throw '\u76ee\u524d\u9810\u8a2d\u548c\u5feb\u7167\u4e0d\u540c\uff0c\u8acb\u5148\u78ba\u8a8d\u5176\u4ed6\u7ba1\u7406\u8005\u7684\u8b8a\u66f4\u3002'\n}\nif ((Get-LineMenuId $testerPath) -cne $candidateId) {\n    throw '\u6e2c\u8a66\u5e33\u865f\u9084\u6c92\u6709\u9023\u7d50\u65b0\u7248\uff0c\u8acb\u5148\u5b8c\u6210\u55ae\u4e00\u5e33\u865f\u6e2c\u8a66\u3002'\n}\n\nAssert-LineOk (Invoke-Line POST \"$defaultPath\/$candidateId\")\nif ((Get-LineMenuId $defaultPath) -cne $candidateId) {\n    throw '\u67e5\u56de\u7684\u9810\u8a2d\u5c1a\u672a\u662f\u65b0\u7248\uff0c\u8acb\u5148\u91cd\u65b0\u67e5\u8a62\u3002'\n}\n'\u65b0\u7248\u5df2\u8a2d\u6210\u9810\u8a2d\u3002'<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E8%A7%A3%E9%99%A4%E6%B8%AC%E8%A9%A6%E5%B8%B3%E8%99%9F%E7%9A%84%E5%80%8B%E4%BA%BA%E9%81%B8%E5%96%AE\"><\/span>\u89e3\u9664\u6e2c\u8a66\u5e33\u865f\u7684\u500b\u4eba\u9078\u55ae<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u82e5\u5df2\u91cd\u958b PowerShell\uff0c\u56de\u5230\u539f\u672c\u7684\u5de5\u4f5c\u76ee\u9304\uff0c\u91cd\u65b0\u8f09\u5165\u6b0a\u6756\u8207\u4e0a\u9762\u7684\u5171\u7528\u6307\u4ee4\u3002\u89e3\u9664\u524d\uff0c\u7a0b\u5f0f\u6703\u8b80\u53d6\u5feb\u7167\uff0c\u6838\u5c0d\u5b98\u65b9\u5e33\u865f\u53ca\u9019\u6b21\u9023\u4e0a\u7684\u500b\u4eba\u9078\u55ae\u3002\u89e3\u9664\u5f8c\uff0c\u7528\u9019\u652f\u6e2c\u8a66\u5e33\u865f\u9a57\u6536\u9810\u8a2d\u9078\u55ae\u7684\u986f\u793a\u3002\u8acb\u5728\u624b\u6a5f\u91cd\u65b0\u9032\u5165\u804a\u5929\u5ba4\u3002LINE \u8aaa\u660e\uff0cMessaging API \u7684\u9810\u8a2d\u8b8a\u66f4\u53ef\u80fd\u9700\u8981\u4e00\u5206\u9418\u624d\u751f\u6548\u3002<a href=\"https:\/\/developers.line.biz\/en\/reference\/messaging-api\/nojs\/#unlink-rich-menu-from-user\" target=\"_blank\" rel=\"noopener\">\u89e3\u9664\u500b\u4eba\u9078\u55ae API<\/a>\u3001<a href=\"https:\/\/developers.line.biz\/en\/docs\/messaging-api\/rich-menus-overview\/\" target=\"_blank\" rel=\"noopener\">\u5716\u6587\u9078\u55ae\u986f\u793a\u6642\u6a5f<\/a><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$saved = Read-LineRollout\n$testerPath = \"user\/$($saved.testerId)\/richmenu\"\nif ((Get-LineMenuId $testerPath) -cne $saved.candidateId) {\n    throw '\u76ee\u524d\u500b\u4eba\u9078\u55ae\u548c\u672c\u6b21\u6e2c\u8a66\u8a2d\u5b9a\u4e0d\u540c\u3002'\n}\nAssert-LineOk (Invoke-Line DELETE $testerPath)\nif (Get-LineMenuId $testerPath) {\n    throw '\u6e2c\u8a66\u5e33\u865f\u4ecd\u6709\u500b\u4eba\u9078\u55ae\uff0c\u8acb\u5148\u78ba\u8a8d\u76ee\u524d\u72c0\u614b\u3002'\n}\n'\u5df2\u89e3\u9664\u6e2c\u8a66\u7528\u7684\u500b\u4eba\u9078\u55ae\u3002'<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E7%94%A8%E5%BF%AB%E7%85%A7%E5%9B%9E%E5%BE%A9%E9%A0%90%E8%A8%AD\"><\/span>\u7528\u5feb\u7167\u56de\u5fa9\u9810\u8a2d<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u9700\u8981\u56de\u5fa9\u6642\uff0c\u56de\u5230\u540c\u4e00\u500b\u5de5\u4f5c\u76ee\u9304\u3002\u5982\u679c\u5df2\u95dc\u9589 PowerShell\uff0c\u5148\u91cd\u65b0\u8f09\u5165\u74b0\u5883\u8b8a\u6578\u8207\u6700\u4e0a\u9762\u7684\u5171\u7528\u6307\u4ee4\u3002\u518d\u6b21\u6838\u5c0d\u6b0a\u6756\u6240\u5c6c\u5b98\u65b9\u5e33\u865f\u548c\u76ee\u524d\u9810\u8a2d\u3002\u5feb\u7167\u6709\u539f\u9810\u8a2d ID\uff0c\u5c31\u8a2d\u56de\u8a72 ID\u3002\u539f\u672c\u7684\u67e5\u8a62\u7d50\u679c\u70ba <code>404<\/code> \u6642\uff0c\u5247\u6e05\u9664\u672c\u6b21\u8a2d\u5b9a\u7684 API \u9810\u8a2d\uff0c\u518d\u67e5\u4e00\u6b21\u78ba\u8a8d\u3002\u82e5\u6e2c\u8a66\u5e33\u865f\u9084\u7559\u8457\u672c\u6b21\u7684\u500b\u4eba\u9078\u55ae\uff0c\u56de\u5230\u4e0a\u4e00\u6bb5\u89e3\u9664\u5f8c\uff0c\u518d\u7528\u624b\u6a5f\u91cd\u65b0\u958b\u555f\u804a\u5929\u756b\u9762\u3002<a href=\"https:\/\/developers.line.biz\/en\/reference\/messaging-api\/nojs\/#clear-default-rich-menu\" target=\"_blank\" rel=\"noopener\">\u6e05\u9664 API \u9810\u8a2d\u9078\u55ae<\/a>\u3001<a href=\"https:\/\/developers.line.biz\/en\/docs\/messaging-api\/stop-displaying-rich-menu\/\" target=\"_blank\" rel=\"noopener\">\u96b1\u85cf\u8207\u89e3\u9664\u5716\u6587\u9078\u55ae<\/a><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$saved = Read-LineRollout\nif ((Get-LineMenuId $defaultPath) -cne $saved.candidateId) {\n    throw '\u76ee\u524d\u9810\u8a2d\u4e0d\u662f\u672c\u6b21\u5207\u63db\u7684\u7248\u672c\uff0c\u8acb\u5148\u78ba\u8a8d\u72c0\u614b\u3002'\n}\n\nif ($saved.previousDefault) {\n    Assert-LineOk (Invoke-Line POST \"$defaultPath\/$($saved.previousDefault)\")\n} else {\n    Assert-LineOk (Invoke-Line DELETE $defaultPath)\n}\nif ((Get-LineMenuId $defaultPath) -cne $saved.previousDefault) {\n    throw '\u67e5\u56de\u7684\u9810\u8a2d\u548c\u5207\u63db\u524d\u5feb\u7167\u4e0d\u4e00\u81f4\u3002'\n}\n'\u5df2\u56de\u5fa9\u5207\u63db\u524d\u7684 API \u9810\u8a2d\u3002'<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u672c\u6587\u7684 PowerShell \u7bc4\u4f8b\u53ef\u7528 HTTP \u56de\u61c9\u6838\u5c0d\u6bcf\u4e00\u6b65\u3002\u5be6\u969b\u986f\u793a\u8acb\u7528\u81ea\u5df1\u7684\u5b98\u65b9\u5e33\u865f\u8207\u6e2c\u8a66\u624b\u6a5f\u9a57\u8b49\u3002\u82e5\u60f3\u7528 Python \u81ea\u52d5\u5316\uff0cLY Corporation \u63d0\u4f9b\u5b98\u65b9\u958b\u6e90 LINE Messaging API SDK for Python\uff0c\u5957\u4ef6\u7684\u4f5c\u8005\u8207\u7dad\u8b77\u8005\u6b04\u4f4d\u767b\u8f09\u70ba RyosukeHasebe\uff0c\u63a1 Apache License 2.0 \u6388\u6b0a\u3002<a href=\"https:\/\/github.com\/line\/line-bot-sdk-python\" target=\"_blank\" rel=\"noopener\">\u5b98\u65b9 Python SDK \u5c08\u6848<\/a>\u3001<a href=\"https:\/\/pypi.org\/project\/line-bot-sdk\/#metadata\" target=\"_blank\" rel=\"noopener\">PyPI \u4f5c\u8005\u8207\u7dad\u8b77\u8005\u8cc7\u6599<\/a>\u3001<a href=\"https:\/\/github.com\/line\/line-bot-sdk-python\/blob\/master\/LICENSE\" target=\"_blank\" rel=\"noopener\">\u5c08\u6848\u6388\u6b0a<\/a><\/p>\n\n\n\n\n<nav class=\"tt5-series-nav\" id=\"series-navigation\" aria-label=\"LINE Bot \u7cfb\u5217\u5c0e\u89bd\">\n<p class=\"tt5-series-nav__title\">LINE Bot \u7cfb\u5217\u5c0e\u89bd<\/p>\n<div class=\"tt5-series-nav__steps\"><a class=\"tt5-series-nav__step\" href=\"\/?p=666\" rel=\"prev\"><span class=\"tt5-series-nav__direction\">\u4e0a\u4e00\u7bc7<\/span> <strong class=\"tt5-series-nav__destination\">\u88fd\u4f5c\u300c\u6559\u5b78\uff0f\u806f\u7d61\u300d\u96d9\u5206\u9801<\/strong><\/a><\/div>\n<div class=\"tt5-series-nav__return\"><a href=\"\/?page_id=16#line-bot\">\u56de\u6559\u5b78\u5c0e\u8b80<\/a><\/div>\n<\/nav>\n","protected":false},"excerpt":{"rendered":"<p>\u65b0\u7248\u5716\u6587\u9078\u55ae\u505a\u597d\u5f8c\uff0c\u53ef\u4ee5\u5148\u6307\u5b9a\u7d66\u4e00\u500b\u6e2c\u8a66\u5e33\u865f\uff0c\u7528\u624b\u6a5f\u78ba\u8a8d\u9078\u55ae\u5916\u89c0\u548c\u9ede\u64ca\u52d5\u4f5c\u3002\u78ba\u8a8d\u7121\u8aa4\u5f8c\uff0c\u518d\u5207\u6210\u5b98\u65b9\u5e33\u865f\u7684\u9810\u8a2d\u9078 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":["post-657","post","type-post","status-publish","format-standard","hentry","category-line-bot"],"_links":{"self":[{"href":"https:\/\/wp.chih-hao.synology.me\/index.php?rest_route=\/wp\/v2\/posts\/657","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wp.chih-hao.synology.me\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wp.chih-hao.synology.me\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wp.chih-hao.synology.me\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wp.chih-hao.synology.me\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=657"}],"version-history":[{"count":2,"href":"https:\/\/wp.chih-hao.synology.me\/index.php?rest_route=\/wp\/v2\/posts\/657\/revisions"}],"predecessor-version":[{"id":684,"href":"https:\/\/wp.chih-hao.synology.me\/index.php?rest_route=\/wp\/v2\/posts\/657\/revisions\/684"}],"wp:attachment":[{"href":"https:\/\/wp.chih-hao.synology.me\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=657"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wp.chih-hao.synology.me\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=657"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wp.chih-hao.synology.me\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=657"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}