{"id":666,"date":"2026-12-03T01:46:49","date_gmt":"2026-12-02T17:46:49","guid":{"rendered":"https:\/\/wp.chih-hao.synology.me\/?p=666"},"modified":"2026-12-03T02:08:39","modified_gmt":"2026-12-02T18:08:39","slug":"line-bot-%e5%9c%96%e6%96%87%e9%81%b8%e5%96%ae%e5%88%86%e9%a0%81%ef%bd%9c%e7%94%a8-richmenuswitch-%e5%88%87%e6%8f%9b%e6%95%99%e5%ad%b8%e8%88%87%e8%81%af%e7%b5%a1","status":"publish","type":"post","link":"https:\/\/wp.chih-hao.synology.me\/?p=666","title":{"rendered":"LINE Bot \u5716\u6587\u9078\u55ae\u5206\u9801\uff5c\u7528 richmenuswitch \u5207\u63db\u6559\u5b78\u8207\u806f\u7d61"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">\u60f3\u8b93 LINE Bot \u7684\u5716\u6587\u9078\u55ae\u50cf\u5206\u9801\u4e00\u6a23\u5207\u63db\uff0c\u53ef\u4ee5\u6e96\u5099\u300c\u6559\u5b78\u300d\u548c\u300c\u806f\u7d61\u300d\u5169\u5f35\u5716\uff0c\u518d\u7528\u5225\u540d\u628a\u5169\u4efd\u9078\u55ae\u63a5\u8d77\u4f86\u3002\u9019\u7bc7\u6703\u5efa\u7acb\u5169\u4efd\u5c0d\u61c9\u7684\u9078\u55ae\uff0c\u5148\u8b93\u4e00\u500b\u6e2c\u8a66\u5e33\u865f\u4f86\u56de\u5207\u63db\uff0c\u6700\u5f8c\u89e3\u9664\u6e2c\u8a66\u8a2d\u5b9a\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5982\u679c\u525b\u958b\u59cb\u63a5\u89f8 Messaging API\uff0c\u53ef\u5148\u505a<a href=\"https:\/\/wp.chih-hao.synology.me\/?p=655\">\u5efa\u7acb\u5716\u6587\u9078\u55ae\u8207\u4e0a\u50b3\u5716\u7247<\/a>\u3002\u6e96\u5099\u516c\u958b\u7d66\u5176\u4ed6\u4eba\u4f7f\u7528\u6642\uff0c\u518d\u642d\u914d<a href=\"https:\/\/wp.chih-hao.synology.me\/?p=657\">\u55ae\u4e00\u5e33\u865f\u9a57\u6536\u3001\u5207\u63db\u9810\u8a2d\u8207\u56de\u5fa9<\/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=666\/#%E4%B8%8B%E8%BC%89%E5%85%A9%E5%BC%B5%E5%9C%96%EF%BC%8C%E6%A0%B8%E5%B0%8D%E9%BB%9E%E6%93%8A%E5%8D%80\" >\u4e0b\u8f09\u5169\u5f35\u5716\uff0c\u6838\u5c0d\u9ede\u64ca\u5340<\/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=666\/#%E5%9C%A8_PowerShell_%E6%BA%96%E5%82%99%E6%AC%8A%E6%9D%96%E8%88%87%E8%A9%A6%E4%BD%9C%E7%B4%80%E9%8C%84\" >\u5728 PowerShell \u6e96\u5099\u6b0a\u6756\u8207\u8a66\u4f5c\u7d00\u9304<\/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=666\/#%E5%BB%BA%E7%AB%8B%E5%85%A9%E4%BB%BD%E9%81%B8%E5%96%AE%EF%BC%8C%E5%88%86%E5%88%A5%E4%B8%8A%E5%82%B3%E5%85%A9%E5%BC%B5%E5%9C%96\" >\u5efa\u7acb\u5169\u4efd\u9078\u55ae\uff0c\u5206\u5225\u4e0a\u50b3\u5169\u5f35\u5716<\/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=666\/#%E6%8A%8A%E3%80%8C%E6%95%99%E5%AD%B8%E3%80%8D%E8%88%87%E3%80%8C%E8%81%AF%E7%B5%A1%E3%80%8D%E5%88%A5%E5%90%8D%E6%8C%87%E5%88%B0%E6%AD%A3%E7%A2%BA_ID\" >\u628a\u300c\u6559\u5b78\u300d\u8207\u300c\u806f\u7d61\u300d\u5225\u540d\u6307\u5230\u6b63\u78ba ID<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/wp.chih-hao.synology.me\/?p=666\/#%E7%94%A8%E5%96%AE%E4%B8%80%E5%B8%B3%E8%99%9F%E6%B8%AC%E8%A9%A6%E5%85%A9%E5%80%8B%E6%96%B9%E5%90%91\" >\u7528\u55ae\u4e00\u5e33\u865f\u6e2c\u8a66\u5169\u500b\u65b9\u5411<\/a><\/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=666\/#%E5%9B%9E%E5%BE%A9%E9%A1%AF%E7%A4%BA%EF%BC%8C%E5%86%8D%E6%B8%85%E7%90%86%E6%9C%AC%E6%AC%A1%E8%A9%A6%E4%BD%9C\" >\u56de\u5fa9\u986f\u793a\uff0c\u518d\u6e05\u7406\u672c\u6b21\u8a66\u4f5c<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E4%B8%8B%E8%BC%89%E5%85%A9%E5%BC%B5%E5%9C%96%EF%BC%8C%E6%A0%B8%E5%B0%8D%E9%BB%9E%E6%93%8A%E5%8D%80\"><\/span>\u4e0b\u8f09\u5169\u5f35\u5716\uff0c\u6838\u5c0d\u9ede\u64ca\u5340<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u628a\u4e0b\u65b9\u5169\u5f35 PNG \u5b58\u5230\u540c\u4e00\u500b\u65b0\u8cc7\u6599\u593e\uff0c\u6a94\u540d\u5206\u5225\u70ba <code>line-rich-menu-teach.png<\/code> \u8207 <code>line-rich-menu-contact.png<\/code>\u3002\u5169\u5f35\u5716\u90fd\u662f 1200 \u00d7 810 \u50cf\u7d20\u3002LINE \u63a5\u53d7 JPEG \u6216 PNG\uff0c\u5716\u5bec\u9700\u5728 800 \u81f3 2500 \u50cf\u7d20\u4e4b\u9593\uff0c\u9ad8\u81f3\u5c11 250 \u50cf\u7d20\uff0c\u5bec\u9ad8\u6bd4\u81f3\u5c11 1.45\uff0c\u6a94\u6848\u4e0a\u9650 1 MB\u3002<a href=\"https:\/\/developers.line.biz\/en\/reference\/messaging-api\/nojs\/#upload-rich-menu-image\" target=\"_blank\" rel=\"noopener\">\u5b98\u65b9\u5716\u6587\u9078\u55ae\u5716\u7247\u898f\u683c<\/a><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/wp.chih-hao.synology.me\/wp-content\/uploads\/2026\/12\/line-rich-menu-teach.png\" alt=\"\u6559\u5b78\u5206\u9801\u7bc4\u4f8b\u5716\u3002\u4e0a\u65b9\u6709\u6559\u5b78\u8207\u806f\u7d61\u5169\u500b\u5206\u9801\uff0c\u4e0b\u65b9\u6709\u57fa\u790e\u6559\u5b78\u8207\u9032\u968e\u8a2d\u5b9a\u5169\u683c\u3002\"\/><figcaption class=\"wp-element-caption\">\u6559\u5b78\u5206\u9801<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/wp.chih-hao.synology.me\/wp-content\/uploads\/2026\/12\/line-rich-menu-contact.png\" alt=\"\u806f\u7d61\u5206\u9801\u7bc4\u4f8b\u5716\u3002\u4e0a\u65b9\u6709\u6559\u5b78\u8207\u806f\u7d61\u5169\u500b\u5206\u9801\uff0c\u4e0b\u65b9\u6709\u806f\u7d61\u65b9\u5f0f\u8207\u50b3\u9001\u8a0a\u606f\u5169\u683c\u3002\"\/><figcaption class=\"wp-element-caption\">\u806f\u7d61\u5206\u9801<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/wp.chih-hao.synology.me\/wp-content\/uploads\/2026\/12\/line-rich-menu-teach.png\">\u4e0b\u8f09\u6559\u5b78\u5206\u9801 PNG<\/a>\u3001<a href=\"https:\/\/wp.chih-hao.synology.me\/wp-content\/uploads\/2026\/12\/line-rich-menu-contact.png\">\u4e0b\u8f09\u806f\u7d61\u5206\u9801 PNG<\/a><\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>\u7bc4\u570d<\/th><th>\u6559\u5b78\u5716<\/th><th>\u806f\u7d61\u5716<\/th><\/tr><\/thead><tbody><tr><td>x 0\u2013599\uff0cy 0\u2013179<\/td><td>\u5207\u5230\u6559\u5b78<\/td><td>\u5207\u5230\u6559\u5b78<\/td><\/tr><tr><td>x 600\u20131199\uff0cy 0\u2013179<\/td><td>\u5207\u5230\u806f\u7d61<\/td><td>\u5207\u5230\u806f\u7d61<\/td><\/tr><tr><td>x 0\u2013599\uff0cy 180\u2013809<\/td><td>\u57fa\u790e\u6559\u5b78<\/td><td>\u806f\u7d61\u65b9\u5f0f<\/td><\/tr><tr><td>x 600\u20131199\uff0cy 180\u2013809<\/td><td>\u9032\u968e\u8a2d\u5b9a<\/td><td>\u50b3\u9001\u8a0a\u606f<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u5ea7\u6a19\u5f9e\u5716\u7247\u5de6\u4e0a\u89d2\u958b\u59cb\u3002\u4e0a\u6392\u5169\u683c\u5404\u662f\u5bec 600\u3001\u9ad8 180\uff0c\u4e0b\u6392\u5404\u662f\u5bec 600\u3001\u9ad8 630\u3002\u5169\u5f35\u5716\u7684\u4e0a\u6392\u7528\u540c\u4e00\u7d44\u5207\u63db\u52d5\u4f5c\uff0c\u4e0b\u6392\u624d\u63db\u6210\u8a72\u5206\u9801\u7684\u5167\u5bb9\u3002<code>richmenuswitch<\/code> \u6307\u5411 <code>richMenuAliasId<\/code>\uff0cLINE \u6703\u5148\u67e5\u9019\u500b\u5225\u540d\uff0c\u518d\u5207\u5230\u5b83\u6307\u5411\u7684 <code>richMenuId<\/code>\u3002<a href=\"https:\/\/developers.line.biz\/en\/docs\/messaging-api\/switch-rich-menus\/\" target=\"_blank\" rel=\"noopener\">LINE \u5b98\u65b9\u5716\u6587\u9078\u55ae\u5206\u9801\u6d41\u7a0b<\/a>\u3001<a href=\"https:\/\/developers.line.biz\/en\/reference\/messaging-api\/nojs\/#richmenu-switch-action\" target=\"_blank\" rel=\"noopener\">\u5207\u63db\u52d5\u4f5c\u6b04\u4f4d<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E5%9C%A8_PowerShell_%E6%BA%96%E5%82%99%E6%AC%8A%E6%9D%96%E8%88%87%E8%A9%A6%E4%BD%9C%E7%B4%80%E9%8C%84\"><\/span>\u5728 PowerShell \u6e96\u5099\u6b0a\u6756\u8207\u8a66\u4f5c\u7d00\u9304<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u5728\u653e\u5169\u5f35\u5716\u7684\u8cc7\u6599\u593e\u958b\u555f PowerShell 7\u3002\u7528\u672c\u6a5f\u5bc6\u9470\u5de5\u5177\u8f09\u5165 <code>LINE_CHANNEL_ACCESS_TOKEN<\/code>\u3002PowerShell 7.2 \u4ee5\u4e0a\u4e5f\u53ef\u4ee5\u57f7\u884c <code>$env:LINE_CHANNEL_ACCESS_TOKEN = Read-Host '\u8cbc\u4e0a Channel access token' -MaskInput<\/code>\uff0c\u7b49\u63d0\u793a\u51fa\u73fe\u518d\u8cbc\u4e0a\u6b0a\u6756\u3002\u5f8c\u9762\u7684\u7bc4\u4f8b\u6703\u628a\u6b0a\u6756\u653e\u5728 LINE \u5b98\u65b9 API \u7684\u6388\u6b0a\u6a19\u982d\uff0c\u8a66\u4f5c\u7d00\u9304\u53ea\u8a18\u9304\u8cc7\u6e90 ID\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>if ([string]::IsNullOrWhiteSpace($env:LINE_CHANNEL_ACCESS_TOKEN)) {\n    throw '\u8acb\u5148\u5728\u9019\u500b PowerShell \u5de5\u4f5c\u968e\u6bb5\u8f09\u5165\u6b0a\u6756\u3002'\n}\n$headers = @{ Authorization = \"Bearer $env:LINE_CHANNEL_ACCESS_TOKEN\" }\n$statePath = Join-Path $PWD 'line-rich-menu-tabs.json'\n\nfunction Invoke-Line {\n    param($method, $path, $json, [string]$png, [switch]$dataHost)\n\n    $domain = if ($dataHost -or $png) { 'api-data.line.me' }\n              else { 'api.line.me' }\n    $request = @{\n        Method = $method\n        Uri = \"https:\/\/$domain\/v2\/bot\/$path\"\n        Headers = $headers\n        SkipHttpErrorCheck = $true\n        MaximumRedirection = 0\n        TimeoutSec = 30\n        ErrorAction = 'Stop'\n    }\n    if ($null -ne $json) {\n        $request.ContentType = 'application\/json; charset=utf-8'\n        $request.Body = $json | ConvertTo-Json -Depth 10 -Compress\n    }\n    if ($png) {\n        $request.ContentType = 'image\/png'\n        $request.InFile = $png\n    }\n    Invoke-WebRequest @request\n}\n\nfunction Assert-LineOk($response) {\n    if ([int]$response.StatusCode -ne 200) {\n        $requestId = $response.Headers['x-line-request-id']\n        throw \"LINE HTTP $($response.StatusCode)\uff0crequest ID $requestId\"\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-LineId($path) {\n    $response = Invoke-Line GET $path\n    if ([int]$response.StatusCode -eq 404) { return $null }\n    Assert-LineOk $response\n    $menuId = ($response.Content | ConvertFrom-Json).richMenuId\n    if (-not $menuId) { throw '\u56de\u61c9\u6c92\u6709 richMenuId\u3002' }\n    $menuId\n}\n\nfunction Read-Tabs {\n    $saved = Get-Content -LiteralPath $statePath -Raw | ConvertFrom-Json\n    $bot = Get-LineJson 'info'\n    if (-not $saved.botUserId -or $bot.userId -cne $saved.botUserId) {\n        throw '\u8a66\u4f5c\u7d00\u9304\u548c\u76ee\u524d\u6b0a\u6756\u7684\u5b98\u65b9\u5e33\u865f\u4e0d\u4e00\u81f4\u3002'\n    }\n    $saved\n}\n\nfunction Save-Tabs($tabs) {\n    $tabs | ConvertTo-Json | Set-Content -LiteralPath $statePath -Encoding utf8\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u7528\u81ea\u5df1\u7684\u6e2c\u8a66\u5e33\u865f\u5148\u52a0\u5165\u8a72\u5b98\u65b9\u5e33\u865f\u3002\u53ef\u5f9e\u5df2\u9a57\u7c3d\u7684 <code>follow<\/code> \u4e8b\u4ef6\u8b80\u53d6 <code>source.userId<\/code>\uff0c\u4e5f\u53ef\u5728\u5df2\u9023\u7d50 Business ID \u7684\u60c5\u6cc1\u4e0b\uff0c\u5230\u540c\u4e00\u500b channel \u7684 <strong>Basic settings<\/strong> \u67e5\u81ea\u5df1\u7684 <strong>Your user ID<\/strong>\u3002\u4e0b\u9762\u540c\u6642\u67e5\u5b98\u65b9\u5e33\u865f\u8207\u6e2c\u8a66\u5e33\u865f\uff0c\u4e26\u8a18\u9304\u76ee\u524d\u7684 API \u9810\u8a2d\u3002\u67e5\u9810\u8a2d\u82e5\u5f97\u5230 <code>404<\/code>\uff0c\u9019\u500b API \u9810\u8a2d\u5c1a\u672a\u8a2d\u5b9a\u3002\u82e5\u6536\u5230 <code>403<\/code>\uff0c\u5148\u5230\u539f\u7ba1\u7406\u4ecb\u9762\u78ba\u8a8d\u5b83\u662f\u5426\u7531 LINE Official Account Manager \u7b49\u5176\u4ed6\u4f86\u6e90\u8a2d\u5b9a\u3002\u67e5\u500b\u4eba\u9078\u55ae\u7684 <code>404<\/code> \u6709\u591a\u7a2e\u539f\u56e0\uff0c\u8acb\u5148\u78ba\u8a8d\u6e2c\u8a66\u624b\u6a5f\u5df2\u52a0\u597d\u53cb\uff0c\u4e14\u500b\u4eba\u8cc7\u6599 API \u6838\u5c0d\u6210\u529f\u3002<a href=\"https:\/\/developers.line.biz\/en\/docs\/messaging-api\/getting-user-ids\/\" target=\"_blank\" rel=\"noopener\">\u5b98\u65b9\u4f7f\u7528\u8005 ID \u8aaa\u660e<\/a>\u3001<a href=\"https:\/\/developers.line.biz\/en\/reference\/messaging-api\/nojs\/#get-default-rich-menu-id\" target=\"_blank\" rel=\"noopener\">\u9810\u8a2d\u67e5\u8a62\u56de\u61c9<\/a><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>if (Test-Path -LiteralPath $statePath) {\n    throw '\u9019\u88e1\u5df2\u6709\u8a66\u4f5c\u7d00\u9304\u3002\u53ef\u63a5\u8457\u505a\u4e0b\u4e00\u6bb5\uff0c\u6216\u63db\u65b0\u76ee\u9304\u505a\u53e6\u4e00\u7d44\u3002'\n}\n$expected = (Read-Host '\u8f38\u5165\u5b98\u65b9\u5e33\u865f\u7684 Basic ID\uff0c\u542b @').Trim()\n$tester = (Read-Host '\u8f38\u5165\u6e2c\u8a66\u5e33\u865f userId').Trim()\nif ($tester -cnotmatch '^U[0-9a-f]{32}$') {\n    throw '\u8acb\u6838\u5c0d\u6e2c\u8a66\u5e33\u865f\u7684 LINE userId\u3002'\n}\n$bot = Get-LineJson 'info'\nif (-not $bot.userId -or $bot.basicId -ne $expected) {\n    throw '\u76ee\u524d\u6b0a\u6756\u6240\u5c6c\u7684\u5b98\u65b9\u5e33\u865f\u8207\u9810\u671f\u4e0d\u4e00\u81f4\u3002'\n}\n$profile = Get-LineJson \"profile\/$tester\"\nif ($profile.userId -cne $tester) { throw '\u6e2c\u8a66\u5e33\u865f\u7121\u6cd5\u6838\u5c0d\u3002' }\nif (Get-LineId \"user\/$tester\/richmenu\") {\n    throw '\u8acb\u6539\u7528\u76ee\u524d\u6c92\u6709\u500b\u4eba\u9078\u55ae\u7684\u6e2c\u8a66\u5e33\u865f\u3002'\n}\n\n$run = 'tabs-' + [guid]::NewGuid().ToString('N').Substring(0, 12)\n$tabs = [pscustomobject]@{\n    botUserId = $bot.userId\n    testerId = $tester\n    previousDefault = Get-LineId 'user\/all\/richmenu'\n    teachAlias = \"$run-teach\"\n    contactAlias = \"$run-contact\"\n    teachId = $null\n    contactId = $null\n}\nforeach ($aliasId in $tabs.teachAlias, $tabs.contactAlias) {\n    if (Get-LineId \"richmenu\/alias\/$aliasId\") {\n        throw '\u6b64\u6b21\u8a66\u4f5c\u7684\u5225\u540d\u5df2\u5b58\u5728\uff0c\u8acb\u91cd\u65b0\u5efa\u7acb\u8a66\u4f5c\u7d00\u9304\u3002'\n    }\n}\nSave-Tabs $tabs\n'\u5df2\u8a18\u9304\u539f\u59cb\u8a2d\u5b9a\u3002'<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E5%BB%BA%E7%AB%8B%E5%85%A9%E4%BB%BD%E9%81%B8%E5%96%AE%EF%BC%8C%E5%88%86%E5%88%A5%E4%B8%8A%E5%82%B3%E5%85%A9%E5%BC%B5%E5%9C%96\"><\/span>\u5efa\u7acb\u5169\u4efd\u9078\u55ae\uff0c\u5206\u5225\u4e0a\u50b3\u5169\u5f35\u5716<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u4ee5\u4e0b\u5148\u7d44\u5408\u5169\u4efd\u9078\u55ae\u7684 JSON\uff0c\u547c\u53eb <code>richmenu\/validate<\/code> \u6aa2\u67e5\u5167\u5bb9\uff0c\u518d\u5efa\u7acb\u9078\u55ae\u3002\u4e0a\u6392\u5207\u63db\u6642\uff0c<code>data<\/code> \u6703\u6210\u70ba postback \u7684\u8fa8\u8b58\u503c\u3002\u6559\u5b78\u5206\u9801\u4e0b\u65b9\u9023\u5230\u7ad9\u5167\u5169\u7bc7\u6587\u7ae0\u3002\u806f\u7d61\u5206\u9801\u4e0b\u65b9\u4e00\u683c\u958b\u555f\u806f\u7d61\u9801\uff0c\u53e6\u4e00\u683c\u6703\u4ee5\u9ede\u64ca\u8005\u7684\u8eab\u5206\u50b3\u9001\u7bc4\u4f8b\u6587\u5b57\u3002\u63db\u6210\u81ea\u5df1\u7684\u9078\u55ae\u6642\uff0c\u5716\u7247\u6587\u5b57\u8207\u9019\u88e1\u7684\u52d5\u4f5c\u8981\u4e00\u8d77\u66f4\u65b0\u3002<a href=\"https:\/\/developers.line.biz\/en\/reference\/messaging-api\/nojs\/#validate-rich-menu-object\" target=\"_blank\" rel=\"noopener\">\u5b98\u65b9\u9a57\u8b49\u7aef\u9ede<\/a>\u3001<a href=\"https:\/\/developers.line.biz\/en\/reference\/messaging-api\/nojs\/#richmenu-switch-action\" target=\"_blank\" rel=\"noopener\">\u5207\u63db\u52d5\u4f5c\u898f\u683c<\/a><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$tabs = Read-Tabs\n$teachFile = Get-Item -LiteralPath '.\\line-rich-menu-teach.png' -ErrorAction Stop\n$contactFile = Get-Item -LiteralPath '.\\line-rich-menu-contact.png' -ErrorAction Stop\nif ($teachFile.Length -gt 1000000 -or $contactFile.Length -gt 1000000) {\n    throw '\u8acb\u4f7f\u7528\u5c0f\u65bc 1 MB \u7684 PNG\u3002'\n}\n\nfunction New-MenuArea($x, $y, $height, $action) {\n    @{ bounds = @{ x = $x; y = $y; width = 600; height = $height }\n       action = $action }\n}\nfunction New-TabMenu($name, $leftAction, $rightAction) {\n    $areas = @(\n        (New-MenuArea 0 0 180 @{\n            type = 'richmenuswitch'; label = '\u6559\u5b78'\n            richMenuAliasId = $tabs.teachAlias; data = 'tab=teach'\n        })\n        (New-MenuArea 600 0 180 @{\n            type = 'richmenuswitch'; label = '\u806f\u7d61'\n            richMenuAliasId = $tabs.contactAlias; data = 'tab=contact'\n        })\n        (New-MenuArea 0 180 630 $leftAction)\n        (New-MenuArea 600 180 630 $rightAction)\n    )\n    @{ size = @{ width = 1200; height = 810 }; selected = $true\n       name = $name; chatBarText = '\u6559\u5b78\u8207\u806f\u7d61'; areas = $areas }\n}\n\n$teachMenu = New-TabMenu $tabs.teachAlias @{\n    type = 'uri'; label = '\u57fa\u790e\u6559\u5b78'; uri = 'https:\/\/wp.chih-hao.synology.me\/?p=655'\n} @{\n    type = 'uri'; label = '\u9032\u968e\u8a2d\u5b9a'; uri = 'https:\/\/wp.chih-hao.synology.me\/?p=657'\n}\n$contactMenu = New-TabMenu $tabs.contactAlias @{\n    type = 'uri'; label = '\u806f\u7d61\u65b9\u5f0f'; uri = 'https:\/\/wp.chih-hao.synology.me\/?page_id=15'\n} @{\n    type = 'message'; label = '\u50b3\u9001\u8a0a\u606f'; text = '\u60a8\u597d\uff0c\u6211\u60f3\u8a62\u554f LINE Bot\u3002'\n}\n\n$targets = @(\n    @{ field = 'teachId'; menu = $teachMenu; file = $teachFile }\n    @{ field = 'contactId'; menu = $contactMenu; file = $contactFile }\n)\nforeach ($target in $targets) {\n    $field = $target.field\n    if (-not $tabs.$field) {\n        Assert-LineOk (Invoke-Line POST 'richmenu\/validate' -json $target.menu)\n        $found = @((Get-LineJson 'richmenu\/list').richmenus |\n            Where-Object { $_.name -ceq $target.menu.name })\n        if ($found.Count -gt 1) { throw '\u767c\u73fe\u591a\u7b46\u540c\u540d\u9078\u55ae\uff0c\u8acb\u5148\u6838\u5c0d ID\u3002' }\n        $menu = if ($found.Count -eq 1) { $found[0] }\n                else {\n                    $res = Invoke-Line POST 'richmenu' -json $target.menu\n                    Assert-LineOk $res\n                    $res.Content | ConvertFrom-Json\n                }\n        if (-not $menu.richMenuId) { throw '\u5efa\u7acb\u56de\u61c9\u6c92\u6709 richMenuId\u3002' }\n        $tabs.$field = $menu.richMenuId\n        Save-Tabs $tabs\n    }\n\n    $imagePath = \"richmenu\/$($tabs.$field)\/content\"\n    $current = Invoke-Line GET $imagePath -dataHost\n    if ([int]$current.StatusCode -eq 404) {\n        Assert-LineOk (Invoke-Line POST $imagePath -png $target.file.FullName)\n    } else {\n        Assert-LineOk $current\n    }\n    Assert-LineOk (Invoke-Line GET $imagePath -dataHost)\n}\n'\u5169\u4efd\u9078\u55ae\u7684\u5716\u7247\u7686\u53ef\u67e5\u56de\u3002'<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u9078\u55ae JSON \u7528 <code>api.line.me<\/code>\uff0c\u5716\u7247\u5247\u7528 <code>api-data.line.me<\/code>\uff0c\u4ee5\u4e0a\u50b3\u7684\u539f\u59cb PNG \u4f5c\u70ba\u8acb\u6c42\u5167\u5bb9\u3002\u7a0b\u5f0f\u6bcf\u5efa\u597d\u4e00\u4efd\u5c31\u8a18\u4e0b ID\u3002\u9047\u5230\u7db2\u8def\u903e\u6642\u53ef\u5728\u540c\u4e00\u500b\u76ee\u9304\u91cd\u8dd1\u672c\u6bb5\uff0c\u7a0b\u5f0f\u6703\u7528\u672c\u6b21\u5c08\u7528\u540d\u7a31\u5c0b\u627e\u5df2\u5efa\u7acb\u7684\u9078\u55ae\uff0c\u4e5f\u6703\u5148\u67e5\u5716\u7247\u662f\u5426\u5df2\u5b58\u5728\u3002\u60f3\u63db\u5716\u6642\uff0c\u9700\u8981\u53e6\u5efa\u9078\u55ae\u4e26\u4e0a\u50b3\u65b0\u5716\u3002<a href=\"https:\/\/developers.line.biz\/en\/reference\/messaging-api\/nojs\/#upload-rich-menu-image\" target=\"_blank\" rel=\"noopener\">\u5716\u7247\u4e0a\u50b3\u8207\u9650\u5236<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E6%8A%8A%E3%80%8C%E6%95%99%E5%AD%B8%E3%80%8D%E8%88%87%E3%80%8C%E8%81%AF%E7%B5%A1%E3%80%8D%E5%88%A5%E5%90%8D%E6%8C%87%E5%88%B0%E6%AD%A3%E7%A2%BA_ID\"><\/span>\u628a\u300c\u6559\u5b78\u300d\u8207\u300c\u806f\u7d61\u300d\u5225\u540d\u6307\u5230\u6b63\u78ba ID<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u5169\u5f35\u5716\u90fd\u4e0a\u50b3\u5f8c\u518d\u5efa\u5225\u540d\u3002<code>GET<\/code> \u6536\u5230 <code>404<\/code> \u5c31\u5efa\u7acb\uff0c\u5df2\u6709\u76f8\u540c\u76ee\u6a19\u5c31\u6cbf\u7528\u3002\u82e5\u8a66\u4f5c\u5225\u540d\u6307\u5230\u9019\u4e00\u7d44\u7684\u53e6\u4e00\u4efd\u9078\u55ae\uff0c\u53ef\u4ee5\u5728\u9019\u88e1\u6539\u56de\u6b63\u78ba\u76ee\u6a19\u3002\u4f7f\u7528\u672c\u6b21\u7684\u96a8\u6a5f\u5225\u540d\uff0c\u53ef\u8b93\u5df2\u4e0a\u7dda\u9078\u55ae\u7684\u5207\u63db\u8def\u5f91\u7dad\u6301\u539f\u6a23\u3002\u5225\u540d\u8b8a\u66f4\u53ef\u80fd\u53d7\u5feb\u53d6\u5f71\u97ff\uff0c\u9001\u51fa\u5f8c\u8acb\u6838\u5c0d API \u8207\u624b\u6a5f\u756b\u9762\u3002<a href=\"https:\/\/developers.line.biz\/en\/reference\/messaging-api\/nojs\/#create-rich-menu-alias\" target=\"_blank\" rel=\"noopener\">\u5efa\u7acb\u5225\u540d<\/a>\u3001<a href=\"https:\/\/developers.line.biz\/en\/reference\/messaging-api\/nojs\/#update-rich-menu-alias\" target=\"_blank\" rel=\"noopener\">\u66f4\u65b0\u5225\u540d<\/a><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$tabs = Read-Tabs\nif (-not $tabs.teachId -or -not $tabs.contactId) {\n    throw '\u8acb\u5148\u5b8c\u6210\u5169\u4efd\u9078\u55ae\u8207\u5716\u7247\u3002'\n}\n$owned = @($tabs.teachId, $tabs.contactId)\n$pairs = @{\n    $tabs.teachAlias = $tabs.teachId\n    $tabs.contactAlias = $tabs.contactId\n}\nforeach ($aliasId in $pairs.Keys) {\n    $targetId = $pairs[$aliasId]\n    $path = \"richmenu\/alias\/$aliasId\"\n    $current = Get-LineId $path\n    if (-not $current) {\n        Assert-LineOk (Invoke-Line POST 'richmenu\/alias' -json @{\n            richMenuAliasId = $aliasId; richMenuId = $targetId\n        })\n    } elseif ($current -cne $targetId) {\n        if ($current -notin $owned) { throw '\u5225\u540d\u76ee\u524d\u6307\u5411\u6b64\u8a66\u4f5c\u4ee5\u5916\u7684\u9078\u55ae\u3002' }\n        Assert-LineOk (Invoke-Line POST $path -json @{ richMenuId = $targetId })\n    }\n    if ((Get-LineId $path) -cne $targetId) {\n        throw '\u5225\u540d\u5c1a\u672a\u6307\u5411\u9810\u671f ID\uff0c\u8acb\u91cd\u65b0\u67e5\u8a62\u5f8c\u518d\u6e2c\u8a66\u3002'\n    }\n}\n'\u5169\u500b\u5225\u540d\u90fd\u5df2\u6307\u5230\u5c0d\u61c9\u7684\u9078\u55ae\u3002'<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E7%94%A8%E5%96%AE%E4%B8%80%E5%B8%B3%E8%99%9F%E6%B8%AC%E8%A9%A6%E5%85%A9%E5%80%8B%E6%96%B9%E5%90%91\"><\/span>\u7528\u55ae\u4e00\u5e33\u865f\u6e2c\u8a66\u5169\u500b\u65b9\u5411<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u5148\u78ba\u8a8d\u5225\u540d\u5c0d\u61c9\uff0c\u518d\u628a\u300c\u6559\u5b78\u300d\u9023\u7d50\u5230\u6e2c\u8a66\u5e33\u865f\u3002\u82e5\u91cd\u505a\u672c\u6bb5\u6642\uff0c\u6e2c\u8a66\u5e33\u865f\u5df2\u5728\u9019\u4e00\u7d44\u7684\u300c\u806f\u7d61\u300d\u5206\u9801\uff0c\u53ef\u5207\u56de\u300c\u6559\u5b78\u300d\u7e7c\u7e8c\u9a57\u6536\u3002<a href=\"https:\/\/developers.line.biz\/en\/docs\/messaging-api\/use-per-user-rich-menus\/\" target=\"_blank\" rel=\"noopener\">\u5b98\u65b9\u500b\u4eba\u9078\u55ae\u6e2c\u8a66\u65b9\u5f0f<\/a><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$tabs = Read-Tabs\nif (-not $tabs.teachId -or -not $tabs.contactId -or\n    (Get-LineId \"richmenu\/alias\/$($tabs.teachAlias)\") -cne $tabs.teachId -or\n    (Get-LineId \"richmenu\/alias\/$($tabs.contactAlias)\") -cne $tabs.contactId) {\n    throw '\u8acb\u5148\u6838\u5c0d\u5169\u500b\u5225\u540d\u3002'\n}\n$userPath = \"user\/$($tabs.testerId)\/richmenu\"\n$linked = Get-LineId $userPath\nif ($linked -and $linked -notin @($tabs.teachId, $tabs.contactId)) {\n    throw '\u6e2c\u8a66\u5e33\u865f\u76ee\u524d\u6709\u5176\u4ed6\u500b\u4eba\u9078\u55ae\u3002'\n}\nAssert-LineOk (Invoke-Line POST \"$userPath\/$($tabs.teachId)\")\nif ((Get-LineId $userPath) -cne $tabs.teachId) {\n    throw '\u500b\u4eba\u9023\u7d50\u672a\u751f\u6548\uff0c\u8acb\u78ba\u8a8d\u6e2c\u8a66\u5e33\u865f\u5df2\u52a0\u5165\u597d\u53cb\u3002'\n}\n$tabs | Select-Object teachId, contactId\nGet-LineId $userPath<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u5728\u624b\u6a5f\u958b\u555f\u76ee\u6a19\u804a\u5929\u756b\u9762\uff0c\u5148\u770b\u662f\u5426\u51fa\u73fe\u300c\u57fa\u790e\u6559\u5b78\uff0f\u9032\u968e\u8a2d\u5b9a\u300d\u3002\u6309\u300c\u806f\u7d61\u300d\u5f8c\uff0c\u61c9\u6539\u6210\u300c\u806f\u7d61\u65b9\u5f0f\uff0f\u50b3\u9001\u8a0a\u606f\u300d\u3002\u6b64\u6642\u5728\u7d42\u7aef\u6a5f\u57f7\u884c <code>Get-LineId $userPath<\/code>\uff0c\u61c9\u986f\u793a\u525b\u624d\u5217\u51fa\u7684 <code>contactId<\/code>\u3002\u518d\u6309\u300c\u6559\u5b78\u300d\u4e26\u91cd\u67e5\u4e00\u6b21\uff0c\u61c9\u56de\u5230 <code>teachId<\/code>\u3002\u6700\u5f8c\u7528\u6e2c\u8a66\u5e33\u865f\u5404\u9ede\u4e00\u6b21\u4e0b\u6392\u6309\u9215\uff0c\u78ba\u8a8d\u5be6\u969b\u6253\u958b\u7684\u9801\u9762\u8207\u6536\u5230\u7684\u6587\u5b57\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5982\u679c\u6309\u4e86\u4e0a\u6392\u537b\u6c92\u63db\u5716\uff0c\u5f9e\u5df2\u9a57\u7c3d\u7684 postback \u4e8b\u4ef6\u770b <code>postback.params.status<\/code>\u3002<code>RICHMENU_ALIAS_ID_NOTFOUND<\/code> \u8868\u793a\u5225\u540d\u67e5\u4e0d\u5230\u3002<code>RICHMENU_NOTFOUND<\/code> \u8868\u793a\u5225\u540d\u6307\u5411\u7684\u9078\u55ae\u5df2\u627e\u4e0d\u5230\u3002\u82e5 API \u5efa\u7acb\u5225\u540d\u56de\u50b3 <code>400<\/code>\uff0c\u5148\u67e5\u76ee\u6a19\u9078\u55ae\u7684\u5716\u7247\u53ca\u5225\u540d\u62fc\u6cd5\u3002\u6536\u5230 <code>401<\/code> \u6642\uff0c\u6838\u5c0d\u9019\u500b\u5de5\u4f5c\u968e\u6bb5\u8f09\u5165\u7684\u6b0a\u6756\u548c\u6709\u6548\u671f\u9650\u3002\u82e5\u525b\u66f4\u65b0\u5225\u540d\u9084\u770b\u5230\u820a\u5716\uff0c\u6838\u5c0d GET \u7684\u6700\u65b0\u5c0d\u61c9\u518d\u6e2c\u4e00\u6b21\u3002<a href=\"https:\/\/developers.line.biz\/en\/reference\/messaging-api\/nojs\/#postback-params-object-for-richmenu-switch-action\" target=\"_blank\" rel=\"noopener\">\u5b98\u65b9 postback \u5207\u63db\u72c0\u614b<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E5%9B%9E%E5%BE%A9%E9%A1%AF%E7%A4%BA%EF%BC%8C%E5%86%8D%E6%B8%85%E7%90%86%E6%9C%AC%E6%AC%A1%E8%A9%A6%E4%BD%9C\"><\/span>\u56de\u5fa9\u986f\u793a\uff0c\u518d\u6e05\u7406\u672c\u6b21\u8a66\u4f5c<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u5982\u679c\u53ea\u505a\u55ae\u4e00\u5e33\u865f\u8a66\u4f5c\uff0c\u53ef\u4ee5\u76f4\u63a5\u5f80\u4e0b\u6e05\u7406\u3002\u82e5\u5df2\u4f9d<a href=\"https:\/\/wp.chih-hao.synology.me\/?p=657\">\u9032\u968e\u7bc7<\/a>\u628a\u9019\u7d44\u9078\u55ae\u8a2d\u70ba\u5168\u9ad4\u9810\u8a2d\uff0c\u9700\u8981\u56de\u5fa9\u6642\u5148\u57f7\u884c\u9019\u4e00\u6bb5\u3002\u5b83\u53ea\u5728\u76ee\u524d\u9810\u8a2d\u4ecd\u5c6c\u65bc\u9019\u4e00\u6b21\u7684\u9078\u55ae\u6642\u64cd\u4f5c\u3002\u8a66\u4f5c\u7d00\u9304\u6709\u539f\u9810\u8a2d ID \u5c31\u8a2d\u56de\u8a72 ID\uff0c\u539f\u672c\u67e5\u8a62\u70ba <code>404<\/code> \u5c31\u6e05\u9664\u9019\u6b21\u7684 API \u9810\u8a2d\u3002<a href=\"https:\/\/developers.line.biz\/en\/reference\/messaging-api\/nojs\/#clear-default-rich-menu\" target=\"_blank\" rel=\"noopener\">\u5b98\u65b9\u6e05\u9664\u9810\u8a2d API<\/a><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$tabs = Read-Tabs\n$defaultPath = 'user\/all\/richmenu'\n$owned = @($tabs.teachId, $tabs.contactId) | Where-Object { $_ }\n$current = Get-LineId $defaultPath\nif (-not $current -or $current -notin $owned) {\n    throw '\u76ee\u524d\u9810\u8a2d\u8207\u672c\u6b21\u4e0a\u7dda\u7248\u672c\u4e0d\u540c\uff0c\u8acb\u5148\u6838\u5c0d\u72c0\u614b\u3002'\n}\n\nif ($tabs.previousDefault) {\n    Assert-LineOk (Invoke-Line POST \"$defaultPath\/$($tabs.previousDefault)\")\n} else {\n    Assert-LineOk (Invoke-Line DELETE $defaultPath)\n}\nif ((Get-LineId $defaultPath) -cne $tabs.previousDefault) {\n    throw '\u56de\u5fa9\u5f8c\u7684\u9810\u8a2d\u8207\u8a66\u4f5c\u7d00\u9304\u4e0d\u4e00\u81f4\uff0c\u8acb\u91cd\u65b0\u67e5\u8a62\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\">\u4e0b\u65b9\u6e05\u7406\u6307\u4ee4\u9069\u7528\u65bc\u53ea\u9023\u7d50\u4e00\u500b\u6e2c\u8a66\u5e33\u865f\u7684\u8a66\u4f5c\u3002\u4f7f\u7528\u8005\u9ede\u904e\u5206\u9801\u5f8c\uff0c\u53ef\u80fd\u6703\u4fdd\u7559\u512a\u5148\u986f\u793a\u7684\u500b\u4eba\u9078\u55ae\u3002\u6b63\u5f0f\u74b0\u5883\u8acb\u5728\u56de\u5fa9\u9810\u8a2d\u5f8c\u8655\u7406\u66fe\u5207\u9801\u7684\u4f7f\u7528\u8005\u9023\u7d50\uff0c\u78ba\u8a8d\u518d\u7121\u4eba\u4f9d\u8cf4\u9019\u7d44\u5206\u9801\u8207\u5225\u540d\uff0c\u518d\u79fb\u9664\u8cc7\u6e90\u3002\u91cd\u958b PowerShell \u6642\uff0c\u56de\u5230\u539f\u8cc7\u6599\u593e\uff0c\u91cd\u65b0\u8f09\u5165\u6b0a\u6756\u8207\u5171\u7528\u6307\u4ee4\u3002<a href=\"https:\/\/developers.line.biz\/en\/docs\/messaging-api\/switch-rich-menus\/\" target=\"_blank\" rel=\"noopener\">\u5b98\u65b9\u5206\u9801\u9078\u55ae\u79fb\u9664\u8aaa\u660e<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5b8c\u6210\u55ae\u4e00\u5e33\u865f\u6e2c\u8a66\u5f8c\uff0c\u5148\u89e3\u9664\u6e2c\u8a66\u5e33\u865f\u7684\u500b\u4eba\u9078\u55ae\uff0c\u518d\u522a\u9664\u672c\u6b21\u7684\u5169\u500b\u5225\u540d\uff0c\u6700\u5f8c\u522a\u9664\u9078\u55ae\u7269\u4ef6\u3002\u6307\u4ee4\u6703\u5148\u6838\u5c0d\u672c\u6b21\u7684\u5225\u540d\u8207\u5169\u4efd\u9078\u55ae ID\u3002<a href=\"https:\/\/developers.line.biz\/en\/docs\/messaging-api\/stop-displaying-rich-menu\/\" target=\"_blank\" rel=\"noopener\">\u5b98\u65b9\u505c\u6b62\u986f\u793a\u8207\u89e3\u9664\u8aaa\u660e<\/a><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$tabs = Read-Tabs\n$owned = @($tabs.teachId, $tabs.contactId) | Where-Object { $_ }\nif ((Get-LineId 'user\/all\/richmenu') -in $owned) {\n    throw '\u8a66\u4f5c\u9078\u55ae\u76ee\u524d\u662f\u9810\u8a2d\uff0c\u8acb\u5148\u56de\u5fa9\u9810\u8a2d\u3002'\n}\n$aliasPaths = foreach ($aliasId in $tabs.teachAlias, $tabs.contactAlias) {\n    $path = \"richmenu\/alias\/$aliasId\"\n    $target = Get-LineId $path\n    if ($target) {\n        if ($target -notin $owned) { throw '\u5225\u540d\u5df2\u6307\u5411\u5176\u4ed6\u9078\u55ae\uff0c\u8acb\u6838\u5c0d\u3002' }\n        $path\n    }\n}\n$userPath = \"user\/$($tabs.testerId)\/richmenu\"\n$linked = Get-LineId $userPath\nif ($linked -in $owned) {\n    Assert-LineOk (Invoke-Line DELETE $userPath)\n    if (Get-LineId $userPath) { throw '\u8acb\u6838\u5c0d\u6e2c\u8a66\u5e33\u865f\u7684\u500b\u4eba\u9078\u55ae\u3002' }\n}\n\nforeach ($path in $aliasPaths) {\n    Assert-LineOk (Invoke-Line DELETE $path)\n}\nforeach ($menuId in $owned) {\n    $path = \"richmenu\/$menuId\"\n    $response = Invoke-Line GET $path\n    if ([int]$response.StatusCode -ne 404) {\n        Assert-LineOk $response\n        Assert-LineOk (Invoke-Line DELETE $path)\n    }\n}\n'\u8a66\u4f5c\u8cc7\u6e90\u5df2\u6e05\u7406\u3002'<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u6e05\u7406\u5f8c\u7528\u624b\u6a5f\u91cd\u65b0\u9032\u5165\u804a\u5929\u5ba4\uff0c\u78ba\u8a8d\u56de\u5230\u539f\u672c\u7684\u986f\u793a\u3002\u4fdd\u7559\u672c\u6a5f\u5716\u7247\u548c\u9019\u6b21\u8a66\u4f5c\u7d00\u9304\uff0c\u4e4b\u5f8c\u67e5 ID \u6216\u5c0d\u7167\u914d\u7f6e\u6703\u6bd4\u8f03\u65b9\u4fbf\u3002<\/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=655\" rel=\"prev\"><span class=\"tt5-series-nav__direction\">\u4e0a\u4e00\u7bc7<\/span> <strong class=\"tt5-series-nav__destination\">\u4e0a\u50b3\u81ea\u88fd\u5716\u7247\u8207\u8a2d\u5b9a\u9ede\u64ca\u5340<\/strong><\/a> <a class=\"tt5-series-nav__step\" href=\"\/?p=657\" rel=\"next\"><span class=\"tt5-series-nav__direction\">\u4e0b\u4e00\u7bc7<\/span> <strong class=\"tt5-series-nav__destination\">\u6e2c\u8a66\u5716\u6587\u9078\u55ae\u3001\u4e0a\u7dda\u8207\u56de\u5fa9<\/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>\u4e0b\u8f09\u300c\u6559\u5b78\u300d\u8207\u300c\u806f\u7d61\u300d\u5169\u5f35\u5716\u6587\u9078\u55ae\uff0c\u7528 PowerShell \u4e0a\u50b3\u5716\u7247\u3001\u5efa\u7acb\u9078\u55ae\u5225\u540d\u8207\u5207\u63db\u52d5\u4f5c\uff0c\u518d\u7528\u81ea\u5df1\u7684 LINE \u5e33\u865f\u6e2c\u8a66\u8207\u56de\u5fa9\u3002<\/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-666","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\/666","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=666"}],"version-history":[{"count":3,"href":"https:\/\/wp.chih-hao.synology.me\/index.php?rest_route=\/wp\/v2\/posts\/666\/revisions"}],"predecessor-version":[{"id":683,"href":"https:\/\/wp.chih-hao.synology.me\/index.php?rest_route=\/wp\/v2\/posts\/666\/revisions\/683"}],"wp:attachment":[{"href":"https:\/\/wp.chih-hao.synology.me\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=666"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wp.chih-hao.synology.me\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=666"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wp.chih-hao.synology.me\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=666"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}