{"id":13013,"date":"2024-08-11T07:00:35","date_gmt":"2024-08-10T22:00:35","guid":{"rendered":"https:\/\/blog.capilano-fw.com\/?p=13013"},"modified":"2024-07-30T18:05:18","modified_gmt":"2024-07-30T09:05:18","slug":"laravel%e3%81%a7line%e3%81%ae%e3%83%aa%e3%83%83%e3%83%81%e3%83%a1%e3%83%8b%e3%83%a5%e3%83%bc%ef%bc%88%e5%88%87%e3%82%8a%e6%9b%bf%e3%81%88%e5%8f%af%ef%bc%89%e3%82%92%e3%81%a4%e3%81%8f%e3%82%8b","status":"publish","type":"post","link":"https:\/\/blog.capilano-fw.com\/?p=13013","title":{"rendered":"Laravel\u3067LINE\u306e\u30ea\u30c3\u30c1\u30e1\u30cb\u30e5\u30fc\uff08\u5207\u308a\u66ff\u3048\u53ef\uff09\u3092\u3064\u304f\u308b"},"content":{"rendered":"<p>\u3055\u3066\u3055\u3066\u3001\u3054\u5b58\u77e5\u306e\u300c<strong>LINE<\/strong>\u300d\u304c\u30e1\u30c3\u30bb\u30fc\u30b8\u30a2\u30d7\u30ea\u3060\u3051\u3058\u3083\u306a\u304f\u3001\u30d3\u30b8\u30cd\u30b9\u3067\u3082\u91cd\u8981\u306a\u306e\u3092\u3054\u5b58\u77e5\u3067\u3057\u3087\u3046\u304b\u3002\u306a\u305c\u306a\u3089\u3001<\/p>\n<p><strong style=\"font-size: 35px;\">9,500\u4e07\u4eba\u3068\u3044\u3046\u5727\u5012\u7684\u306a\u30e6\u30fc\u30b6\u30fc\u304c\u3044\u308b\u304b\u3089<\/strong><\/p>\n<p>\u3067\u3059\u306d\u3002<\/p>\n<p>\u3057\u304b\u3082\u30011\u65e5\u306b1\u56de\u4ee5\u4e0a\u5229\u7528\u3059\u308b\u30e6\u30fc\u30b6\u30fc\u306f<code>86%<\/code>\uff01<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-13014\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2024\/07\/laravel-line-richmenu-001.png\" alt=\"\" width=\"712\" height=\"363\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2024\/07\/laravel-line-richmenu-001.png 712w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2024\/07\/laravel-line-richmenu-001-300x153.png 300w\" sizes=\"auto, (max-width: 712px) 100vw, 712px\" \/><br \/>\n<small><strong>\u5f15\u7528\uff1a<\/strong><a href=\"https:\/\/campus.line.biz\/line-ads\/courses\/user\/lessons\/oada-1-2-2\" target=\"_blank\" rel=\"noopener\">LINE\u306e\u30e6\u30fc\u30b6\u30fc\u306f\u3069\u3093\u306a\u4eba\uff1f &#8211; LINE\u30ad\u30e3\u30f3\u30d1\u30b9<\/a><\/small><\/p>\n<p>\u5b9f\u969b\u306b\u79c1\u30821\u65e5\u306b\u6570\u56de\u4f7f\u3063\u3066\u3044\u308b\u5370\u8c61\u3067\u3059\u3002<br \/>\n\u305d\u3057\u3066\u3001\u4eca\u56de<code>LINE<\/code>\u3067\u3064\u304f\u308a\u305f\u304f\u306a\u3063\u305f\u306e\u306f\u30fb\u30fb\u30fb\u30fb\u30fb\u30fb<\/p>\n<p><strong style=\"font-size: 35px;\">\u30ea\u30c3\u30c1\u30e1\u30cb\u30e5\u30fc<\/strong><\/p>\n<p>\u3067\u3059\u3002<\/p>\n<p>\u30ea\u30c3\u30c1\u30e1\u30cb\u30e5\u30fc\u3068\u306f\u3001<code>LINE<\/code>\u306e\u30bf\u30a4\u30e0\u30e9\u30a4\u30f3\u4e0b\u90e8\u306b\u8868\u793a\u3055\u308c\u308b\u30e1\u30cb\u30e5\u30fc\u306e\u3053\u3068\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-13066\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2024\/08\/laravel-line-richmenu-024.png\" alt=\"\" width=\"300\" height=\"650\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2024\/08\/laravel-line-richmenu-024.png 300w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2024\/08\/laravel-line-richmenu-024-138x300.png 138w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/p>\n<p>\u30ea\u30c3\u30c1\u30e1\u30cb\u30e5\u30fc\u306f\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u4f7f\u308f\u308c\u305f\u308a\u3057\u307e\u3059\u3002<\/p>\n<ul>\n<li>\u52d5\u753b\u3092\u914d\u4fe1\u3059\u308b<\/li>\n<li>\u8a3a\u65ad\u6a5f\u80fd\u3092\u958b\u59cb\u3059\u308b<\/li>\n<li>\u8ca9\u58f2\u30da\u30fc\u30b8\u3078\u79fb\u52d5\u3059\u308b<\/li>\n<\/ul>\n<p><mark>\u3064\u307e\u308a\u3001<strong>\u30de\u30fc\u30b1\u30c6\u30a3\u30f3\u30b0\u3068\u3057\u3066\u6d3b\u7528\u3055\u308c\u3066\u3044\u308b<\/strong>\u308f\u3051\u3067\u3059\u306d\u3002<\/mark><\/p>\n<p>\u305d\u3053\u3067\uff01<\/p>\n<p><code>Laravel<\/code>\u3092\u4f7f\u3063\u3066\u30ea\u30c3\u30c1\u30e1\u30cb\u30e5\u30fc\u3092\u5207\u308a\u66ff\u3048\u308b\u6a5f\u80fd\u3092\u3064\u304f\u3063\u3066\u307f\u307e\u3059\u3002<\/p>\n<p>\u4eca\u56de\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u65b9\u3092\u60f3\u5b9a\u3057\u3066\u8a18\u4e8b\u3092\u66f8\u304d\u307e\u3057\u305f\u3002<\/p>\n<ul>\n<li>\u30ea\u30c3\u30c1\u30e1\u30cb\u30e5\u30fc\u304c\u3069\u3093\u306a\u3082\u306e\u304b\u77e5\u308a\u305f\u3044<\/li>\n<li>\u30ea\u30c3\u30c1\u30e1\u30cb\u30e5\u30fc\u3068Laravel\u304c\u3069\u3046\u9023\u643a\u3059\u308b\u306e\u304b\u77e5\u3063\u3066\u304a\u304d\u305f\u3044<\/li>\n<li>\u30ea\u30c3\u30c1\u30e1\u30cb\u30e5\u30fc\u3092\u3064\u304b\u3063\u3066\u30de\u30fc\u30b1\u30c6\u30a3\u30f3\u30b0\u306b\u5f79\u7acb\u3066\u305f\u3044<\/li>\n<\/ul>\n<p>\u305c\u3072\u6700\u5f8c\u307e\u3067\u8aad\u3093\u3067\u304f\u3060\u3055\u3044\u306d\uff01<\/p>\n<p style=\"text-align: center;\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-9470 aligncenter\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2021\/08\/no_13.png\" alt=\"\" width=\"294\" height=\"320\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2021\/08\/no_13.png 294w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2021\/08\/no_13-276x300.png 276w\" sizes=\"auto, (max-width: 294px) 100vw, 294px\" \/>\u300c18\u304d\u3063\u3077\u3092\u4f7f\u3063\u3066\u3001<br \/>\n\u7247\u90532\u6642\u9593\u306e\u753a\u306b\u3042\u308b<br \/>\n\u30d3\u30fc\u30eb\u91b8\u9020\u6240\u3044\u3063\u3066\u304d\u307e\u3057\u305f\ud83c\udf7b\u300d<\/p>\n<h2>\u30ea\u30c3\u30c1\u30e1\u30cb\u30e5\u30fc\u3092\u64cd\u4f5c\u3059\u308bLINE Messaging API\u304c\u4f7f\u3048\u308b\u3088\u3046\u306b\u3059\u308b<\/h2>\n<p>\u524d\u63d0\u3068\u3057\u3066<code>LINE Messaging API<\/code>\u304c\u4f7f\u3048\u306a\u3044\u3068\u4f55\u3082\u3067\u304d\u307e\u305b\u3093\u3002<\/p>\n<p>\u3053\u306e\u30d6\u30ed\u30b0\u3067\u306f\u4ee5\u4e0b\u306e\u30da\u30fc\u30b8\u3067\u624b\u9806\u3092\u307e\u3068\u3081\u3066\u307e\u3059\u306e\u3067\u3001\u5148\u306b\u6e96\u5099\u3092\u3057\u3066\u304a\u3044\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p><strong>\ud83d\udcdd\u53c2\u8003\u30da\u30fc\u30b8\uff1a<\/strong><a href=\"https:\/\/blog.capilano-fw.com\/?p=12564#i-2\" target=\"_blank\" rel=\"noopener\">Laravel\uff1a LINE \u306e\u9867\u5ba2\u30ea\u30b9\u30c8\u3092\u5931\u308f\u306a\u3044\u30ea\u30b9\u30af\u30d8\u30c3\u30b8\uff08\u524d\u63d0\u3068\u3057\u3066\uff09<\/a><\/p>\n<p>\u203b\u4eca\u56de\u306f\u30c6\u30b9\u30c8\u306a\u306e\u3067<code>ngrok<\/code>\u3092\u3064\u304b\u3063\u3066\u30ed\u30fc\u30ab\u30eb\u3067\u904b\u7528\u3057\u307e\u3059\u3002<\/p>\n<h2>\u30ea\u30c3\u30c1\u30e1\u30cb\u30e5\u30fc\u306a\u3069\u5404\u7a2e\u30c7\u30fc\u30bf\u304c\u4fdd\u6301\u3067\u304d\u308b\u3088\u3046\u306b\u3059\u308b<\/h2>\n<p>\u5fc5\u8981\u306b\u306a\u308b\u306e\u306f\u53cb\u3060\u3061\u767b\u9332\u3057\u3066\u304f\u308c\u305f<code>LINE<\/code>\u30e6\u30fc\u30b6\u30fc\u306e\u60c5\u5831\u3067\u3059\u3002<br \/>\n\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3067\u30b5\u30af\u30c3\u3068\u3064\u304f\u3063\u3066\u3044\u304d\u307e\u3057\u3087\u3046\uff01<\/p>\n<div>\n<pre><strong>php artisan make:model LineUser -m<\/strong><\/pre>\n<\/div>\n<p>\u30d5\u30a1\u30a4\u30eb\u304c2\u3064\u4f5c\u6210\u3055\u308c\u307e\u3059\u3002<br \/>\n\u305d\u308c\u305e\u308c\u4e2d\u8eab\u3092\u5909\u66f4\u3057\u307e\u3057\u3087\u3046\uff01<\/p>\n<p><strong>database\/migrations\/****_**_**_******_create_line_users_table.php<\/strong><\/p>\n<div>\n<pre><strong>&lt;?php<\/strong>\r\n\r\n<strong>use Illuminate\\Database\\Migrations\\Migration;<\/strong>\r\n<strong>use Illuminate\\Database\\Schema\\Blueprint;<\/strong>\r\n<strong>use Illuminate\\Support\\Facades\\Schema;<\/strong>\r\n\r\n<strong>return new class extends Migration<\/strong>\r\n<strong>{<\/strong>\r\n<strong>    \/**<\/strong>\r\n<strong>     * Run the migrations.<\/strong>\r\n<strong>     *\/<\/strong>\r\n<strong>    public function up(): void<\/strong>\r\n<strong>    {<\/strong>\r\n<strong>        Schema::create('line_users', function (Blueprint $table) {<\/strong>\r\n<strong>            $table-&gt;id();<\/strong>\r\n<strong>            $table-&gt;string('line_id')-&gt;comment('LINE\u306eID');<\/strong>\r\n<strong>            $table-&gt;string('mode')-&gt;comment('\u30c1\u30e3\u30cd\u30eb\u306e\u72b6\u614b');<\/strong>\r\n<strong>            $table-&gt;string('display_name')-&gt;comment('LINE\u306e\u540d\u524d');<\/strong>\r\n<strong>            $table-&gt;string('rich_menu_type')-&gt;comment('\u30ea\u30c3\u30c1\u30e1\u30cb\u30e5\u30fc\u306e\u7a2e\u985e');<\/strong>\r\n<strong>            $table-&gt;timestamps();<\/strong>\r\n<strong>        });<\/strong>\r\n<strong>    }<\/strong>\r\n\r\n<strong>    \/**<\/strong>\r\n<strong>     * Reverse the migrations.<\/strong>\r\n<strong>     *\/<\/strong>\r\n<strong>    public function down(): void<\/strong>\r\n<strong>    {<\/strong>\r\n<strong>        Schema::dropIfExists('line_users');<\/strong>\r\n<strong>    }<\/strong>\r\n<strong>};<\/strong><\/pre>\n<\/div>\n<p><strong>app\/Models\/LineUser.php<\/strong><\/p>\n<div>\n<pre><strong>&lt;?php<\/strong>\r\n\r\n<strong>namespace App\\Models;<\/strong>\r\n\r\n<strong>use Illuminate\\Database\\Eloquent\\Factories\\HasFactory;<\/strong>\r\n<strong>use Illuminate\\Database\\Eloquent\\Model;<\/strong>\r\n\r\n<strong>class LineUser extends Model<\/strong>\r\n<strong>{<\/strong>\r\n<strong>    use HasFactory;<\/strong>\r\n\r\n<strong>    protected $fillable = [<\/strong>\r\n<strong>        'line_id',<\/strong>\r\n<strong>        'mode',<\/strong>\r\n<strong>        'display_name',<\/strong>\r\n<strong>        'rich_menu_type',<\/strong>\r\n<strong>    ];<\/strong>\r\n<strong>}<\/strong><\/pre>\n<\/div>\n<p>\u3067\u306f\u3053\u306e\u72b6\u614b\u3067\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3092\u521d\u671f\u5316\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<br \/>\n\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<div>\n<pre><strong>php artisan migrate:fresh --seed<\/strong><\/pre>\n<p>\u5b9f\u969b\u306e\u30c6\u30fc\u30d6\u30eb\u306f\u3053\u3046\u306a\u308a\u307e\u3057\u305f\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-13063 border-3\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2024\/08\/laravel-line-richmenu-023.png\" alt=\"\" width=\"470\" height=\"307\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2024\/08\/laravel-line-richmenu-023.png 470w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2024\/08\/laravel-line-richmenu-023-300x196.png 300w\" sizes=\"auto, (max-width: 470px) 100vw, 470px\" \/><\/p>\n<h2>\u30ea\u30c3\u30c1\u30e1\u30cb\u30e5\u30fc\u306e\u80cc\u666f\u306b\u3064\u304b\u3046\u753b\u50cf\u3092\u7528\u610f\u3059\u308b<\/h2>\n<p>\u30ea\u30c3\u30c1\u30e1\u30cb\u30e5\u30fc\u3067\u8868\u793a\u3059\u308b\u753b\u50cf\u3092\u7528\u610f\u3057\u307e\u3059\u3002<\/p>\n<p><mark>\u3068\u3044\u3046\u306e\u3082\u3001<strong>\u30ea\u30c3\u30c1\u30e1\u30cb\u30e5\u30fc\u3067\u8868\u793a\u3055\u308c\u308b\u30dc\u30bf\u30f3\u306e\u5b9f\u4f53\u306f\u5358\u306a\u308b\u753b\u50cf<\/strong>\u306a\u3093\u3067\u3059\u3002<\/mark><br \/>\n\u4ed5\u69d8\u3068\u3057\u3066\u306f\u3053\u3093\u306a\u30ab\u30f3\u30b8\u3067\u3059\u3002<\/p>\n<ol>\n<li>\u753b\u50cf\u3092\u30bf\u30c3\u30d7\u3059\u308b<\/li>\n<li>\u30bf\u30c3\u30d7\u3055\u308c\u305f\u753b\u50cf\u306e\u5834\u6240\u306b\u3088\u3063\u3066\u30a2\u30af\u30b7\u30e7\u30f3\u304c\u5909\u308f\u308b<\/li>\n<\/ol>\n<p>\u4eca\u56de\u306f\u305d\u3053\u307e\u3067\u304d\u308c\u3044\u306a\u753b\u50cf\u306f\u4e0d\u8981\u306a\u306e\u3067\u3001<code>LINE<\/code>\u304c\u30b5\u30f3\u30d7\u30eb\u3067\u7528\u610f\u3057\u3066\u304f\u308c\u3066\u308b\u3082\u306e\u3092\u3064\u304b\u3063\u3066\u5b9f\u88c5\u3057\u307e\u3057\u3087\u3046\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-13050 border-3\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2024\/07\/laravel-line-richmenu-010.png\" alt=\"\" width=\"640\" height=\"216\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2024\/07\/laravel-line-richmenu-010.png 640w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2024\/07\/laravel-line-richmenu-010-300x101.png 300w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/p>\n<p>\u753b\u50cf\u306f\u300c<strong>storage\/app\/rich_menu_images\/background.png<\/strong>\u300d\u3068\u3057\u3066\u8a2d\u7f6e\u3057\u3066\u304a\u3044\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>\u203b\u306a\u304a\u3001\u30b5\u30f3\u30d7\u30eb\u753b\u50cf\u306e\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u306f\u3001\u4ee5\u4e0b\u306e\u3068\u304a\u308a\u3067\u3059\u3002<\/p>\n<ol>\n<li><a href=\"https:\/\/manager.line.biz\/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">LINE Official Account Manager<\/a>\u306b\u30a2\u30af\u30bb\u30b9<\/li>\n<li>\u30ea\u30c3\u30c1\u30e1\u30cb\u30e5\u30fc\u3092\u8ffd\u52a0\u3057\u305f\u3044\u30c1\u30e3\u30f3\u30cd\u30eb\u3092\u30af\u30ea\u30c3\u30af<\/li>\n<li>\u753b\u9762\u5de6\u5074\u306e\u300c\u30ea\u30c3\u30c1\u30e1\u30cb\u30e5\u30fc\u300d\u3092\u30af\u30ea\u30c3\u30af<\/li>\n<li>\u300c\u30c7\u30b6\u30a4\u30f3\u30ac\u30a4\u30c9\u300d\u3068\u3044\u3046\u30dc\u30bf\u30f3\u3092\u30af\u30ea\u30c3\u30af<\/li>\n<li>\u300c\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3092\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u300d\u30dc\u30bf\u30f3\u3092\u30af\u30ea\u30c3\u30af<\/li>\n<\/ol>\n<\/div>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-13049 border-3\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2024\/07\/laravel-line-richmenu-016.png\" alt=\"\" width=\"595\" height=\"515\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2024\/07\/laravel-line-richmenu-016.png 595w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2024\/07\/laravel-line-richmenu-016-300x260.png 300w\" sizes=\"auto, (max-width: 595px) 100vw, 595px\" \/><\/p>\n<div>\n<h2>\u30ea\u30c3\u30c1\u30e1\u30cb\u30e5\u30fc\u3092\u767b\u9332\u3067\u304d\u308bArtisan\u30b3\u30de\u30f3\u30c9\u3092\u3064\u304f\u308b<\/h2>\n<\/div>\n<p>\u7d50\u8ad6\u304b\u3089\u8a00\u3046\u3068\u3001\u30a6\u30a7\u30d6\u4e0a\uff08<code>LINE Official Account Manager<\/code>\uff09\u3067\u30ea\u30c3\u30c1\u30e1\u30cb\u30e5\u30fc\u3092\u3064\u304f\u308b\u3068\u5207\u308a\u66ff\u3048\u306f\u3067\u304d\u307e\u305b\u3093\u3002<\/p>\n<p><mark>\u30a6\u30a7\u30d6\u7248\u306f\u3001<strong>\u8868\u793a\u671f\u9593\u304c\u91cd\u8907\u3057\u3066\u3044\u308b\u3068\u767b\u9332\u3067\u304d\u306a\u3044<\/strong>\u304b\u3089\u3067\u3059\u3002<\/mark><\/p>\n<p>\u3067\u306f\u3069\u3046\u3059\u308b\u304b\u3068\u8a00\u3046\u3068\u3001\u30d7\u30ed\u30b0\u30e9\u30e0\u304b\u3089\u30ea\u30c3\u30c1\u30e1\u30cb\u30e5\u30fc\u3092\u3064\u304f\u308a\u307e\u3059\u3002\uff08\u203b<code>postman<\/code>\u3067\u3082\u3044\u3044\u3067\u3059\u306d\uff09<\/p>\n<p>\u305d\u306e\u305f\u3081\u3001<code>Laravel<\/code>\u306e<code>Artisan<\/code>\u30b3\u30de\u30f3\u30c9\u3092\u3064\u304f\u308a\u307e\u3059\uff01<br \/>\n\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<div>\n<pre><strong>php artisan make:command MakeLineRichMenuCommand\r\n<\/strong><\/pre>\n<p>\u30d5\u30a1\u30a4\u30eb\u304c\u4f5c\u6210\u3055\u308c\u308b\u306e\u3067\u4e2d\u8eab\u3092\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u5909\u66f4\u3057\u307e\u3059\u3002<\/p>\n<\/div>\n<p><strong>app\/Console\/Commands\/MakeLineRichMenuCommand.php<\/strong><\/p>\n<div>\n<pre><strong>&lt;?php<\/strong>\r\n\r\n<strong>namespace App\\Console\\Commands;<\/strong>\r\n\r\n<strong>use Illuminate\\Console\\Command;<\/strong>\r\n<strong>use Illuminate\\Support\\Facades\\Http;<\/strong>\r\n\r\n<strong>class MakeLineRichMenuCommand extends Command<\/strong>\r\n<strong>{<\/strong>\r\n<strong>    \/**<\/strong>\r\n<strong>     * The name and signature of the console command.<\/strong>\r\n<strong>     *<\/strong>\r\n<strong>     * @var string<\/strong>\r\n<strong>     *\/<\/strong>\r\n<strong>    protected $signature = 'make:line-rich-menu {name} {action_text}';<\/strong>\r\n\r\n<strong>    \/**<\/strong>\r\n<strong>     * The console command description.<\/strong>\r\n<strong>     *<\/strong>\r\n<strong>     * @var string<\/strong>\r\n<strong>     *\/<\/strong>\r\n<strong>    protected $description = 'LINE\u306e\u30ea\u30c3\u30c1\u30e1\u30cb\u30e5\u30fc\u3092\u4f5c\u6210\u3057\u307e\u3059';<\/strong>\r\n\r\n<strong>    \/**<\/strong>\r\n<strong>     * Execute the console command.<\/strong>\r\n<strong>     *\/<\/strong>\r\n<strong>    public function handle()<\/strong>\r\n<strong>    {<\/strong>\r\n<strong>        $access_token = env('LINE_ACCESS_TOKEN'); \/\/ \u672c\u6765\u306fconfig\u304b\u3089\u53d6\u5f97\u3059\u3079\u304d<\/strong>\r\n<strong>        $this-&gt;client = Http::withToken($access_token);<\/strong>\r\n\r\n<strong>        $name = $this-&gt;argument('name');<\/strong>\r\n<strong>        $action_text = $this-&gt;argument('action_text');<\/strong>\r\n\r\n<strong>        $rich_menu_id = $this-&gt;createRichMenu($name, $action_text);<\/strong>\r\n<strong>        $image_path = storage_path('app\/rich_menu_images\/background.png');<\/strong>\r\n<strong>        $result = $this-&gt;uploadRichMenuImage($rich_menu_id, $image_path);<\/strong>\r\n\r\n<strong>        if($result === true) {<\/strong>\r\n\r\n<strong>            $this-&gt;info('\u30ea\u30c3\u30c1\u30e1\u30cb\u30e5\u30fc\u306e\u4f5c\u6210\u306b\u6210\u529f\u3057\u307e\u3057\u305f');<\/strong>\r\n\r\n<strong>        } else {<\/strong>\r\n\r\n<strong>            $this-&gt;error('\u30ea\u30c3\u30c1\u30e1\u30cb\u30e5\u30fc\u306e\u4f5c\u6210\u306b\u5931\u6557\u3057\u307e\u3057\u305f');<\/strong>\r\n\r\n<strong>        }<\/strong>\r\n<strong>    }<\/strong>\r\n\r\n<strong>    private function createRichMenu(string $name, string $action_text): string<\/strong>\r\n<strong>    {<\/strong>\r\n<strong>        $rich_menu_data = [<\/strong>\r\n<strong>            'size' =&gt; [<\/strong>\r\n<strong>                'width' =&gt; 1200,<\/strong>\r\n<strong>                'height' =&gt; 405,<\/strong>\r\n<strong>            ],<\/strong>\r\n<strong>            'selected' =&gt; false,<\/strong>\r\n<strong>            'name' =&gt; $name,<\/strong>\r\n<strong>            'chatBarText' =&gt; '\u30e1\u30cb\u30e5\u30fc',<\/strong>\r\n<strong>            'areas' =&gt; [<\/strong>\r\n<strong>                [<\/strong>\r\n<strong>                    'bounds' =&gt; [<\/strong>\r\n<strong>                        'x' =&gt; 0,<\/strong>\r\n<strong>                        'y' =&gt; 0,<\/strong>\r\n<strong>                        'width' =&gt; 800,<\/strong>\r\n<strong>                        'height' =&gt; 405,<\/strong>\r\n<strong>                    ],<\/strong>\r\n<strong>                    'action' =&gt; [<\/strong>\r\n<strong>                        'type' =&gt; 'message',<\/strong>\r\n<strong>                        'label' =&gt; '\u5de6\u5074\u30dc\u30bf\u30f3',<\/strong>\r\n<strong>                        'text' =&gt; $action_text,<\/strong>\r\n<strong>                    ],<\/strong>\r\n<strong>                ],<\/strong>\r\n<strong>                [<\/strong>\r\n<strong>                    'bounds' =&gt; [<\/strong>\r\n<strong>                        'x' =&gt; 800,<\/strong>\r\n<strong>                        'y' =&gt; 0,<\/strong>\r\n<strong>                        'width' =&gt; 400,<\/strong>\r\n<strong>                        'height' =&gt; 405,<\/strong>\r\n<strong>                    ],<\/strong>\r\n<strong>                    'action' =&gt; [<\/strong>\r\n<strong>                        'type' =&gt; 'message',<\/strong>\r\n<strong>                        'label' =&gt; '\u53f3\u5074\u30dc\u30bf\u30f3',<\/strong>\r\n<strong>                        'text' =&gt; '\u30ea\u30c3\u30c1\u30e1\u30cb\u30e5\u30fc\u5207\u308a\u66ff\u3048',<\/strong>\r\n<strong>                    ],<\/strong>\r\n<strong>                ],<\/strong>\r\n<strong>            ],<\/strong>\r\n<strong>        ];<\/strong>\r\n\r\n<strong>        try {<\/strong>\r\n\r\n<strong>            $response = $this-&gt;client<\/strong>\r\n<strong>                -&gt;withHeader('Content-Type', 'application\/json')<\/strong>\r\n<strong>                -&gt;post('https:\/\/api.line.me\/v2\/bot\/richmenu', $rich_menu_data);<\/strong>\r\n<strong>            $rich_menu_id = $response-&gt;json('richMenuId');<\/strong>\r\n\r\n<strong>            $this-&gt;info('RichMenuId: ' . $rich_menu_id);<\/strong>\r\n\r\n<strong>            return $rich_menu_id;<\/strong>\r\n\r\n<strong>        } catch (\\Exception $e) {<\/strong>\r\n\r\n<strong>            throw $e;<\/strong>\r\n\r\n<strong>        }<\/strong>\r\n<strong>    }<\/strong>\r\n\r\n<strong>    private function uploadRichMenuImage(string $rich_menu_id, string $image_path): bool<\/strong>\r\n<strong>    {<\/strong>\r\n<strong>        try {<\/strong>\r\n\r\n<strong>            $response = $this-&gt;client<\/strong>\r\n<strong>                -&gt;withHeaders([<\/strong>\r\n<strong>                    'Content-Type' =&gt; 'image\/png',<\/strong>\r\n<strong>                ])<\/strong>\r\n<strong>                -&gt;withBody(fopen($image_path, 'r'), 'image\/png')<\/strong>\r\n<strong>                -&gt;post('https:\/\/api-data.line.me\/v2\/bot\/richmenu\/'. $rich_menu_id .'\/content');<\/strong>\r\n\r\n<strong>            $this-&gt;info($response-&gt;body());<\/strong>\r\n\r\n<strong>            return $response-&gt;ok();<\/strong>\r\n\r\n<strong>        } catch (\\Exception $e) {<\/strong>\r\n\r\n<strong>            throw $e;<\/strong>\r\n\r\n<strong>        }<\/strong>\r\n<strong>    }<\/strong>\r\n<strong>}<\/strong><\/pre>\n<p>\u3053\u3053\u3067\u3084\u3063\u3066\u3044\u308b\u624b\u9806\u306f\u4ee5\u4e0b\u306e\u3068\u304a\u308a\u3067\u3059\u3002<\/p>\n<ol>\n<li>\u30ea\u30c3\u30c1\u30e1\u30cb\u30e5\u30fc\u672c\u4f53\u3092\u4f5c\u6210<\/li>\n<li>\u7d50\u679c\u304b\u3089\u30ea\u30c3\u30c1\u30e1\u30cb\u30e5\u30fcID\u3092\u53d6\u5f97<\/li>\n<li>ID\u3092\u4f7f\u3063\u3066\u753b\u50cf\u3092\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9<\/li>\n<\/ol>\n<p>\u3064\u307e\u308a2\u6bb5\u968e\u3067<code>API<\/code>\u306b\u30a2\u30af\u30bb\u30b9\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u3053\u308c\u3067\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3059\u308b\u3068\u3001\u30ea\u30c3\u30c1\u30e1\u30cb\u30e5\u30fc\u304c\u767b\u9332\u3055\u308c\u753b\u50cf\u3082\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u3055\u308c\u308b\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<div>\n<pre><strong>php artisan make:line-rich-menu \"\u30ea\u30c3\u30c1\u30e1\u30cb\u30e5\u30fc1\" \"\u30ea\u30c3\u30c1\u30e1\u30cb\u30e5\u30fc1\u304c\u30bf\u30c3\u30d7\u3055\u308c\u307e\u3057\u305f\"<\/strong><\/pre>\n<p>\u3067\u306f\u3001\u4e0a\u8a18\u306e\u30b3\u30de\u30f3\u30c9\u3068\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u30672\u3064\u30ea\u30c3\u30c1\u30e1\u30cb\u30e5\u30fc\u3092\u3064\u304f\u308a\u3001ID\u3092\u53d6\u5f97\u3057\u3066\u304a\u304d\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre><strong>php artisan make:line-rich-menu \"\u30ea\u30c3\u30c1\u30e1\u30cb\u30e5\u30fc2\" \"\u30ea\u30c3\u30c1\u30e1\u30cb\u30e5\u30fc2\u304c\u30bf\u30c3\u30d7\u3055\u308c\u307e\u3057\u305f\"<\/strong><\/pre>\n<p>\u3046\u307e\u304f\u3044\u304f\u3068\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<code>{}<\/code>\u306f\u6210\u529f\u3057\u305f\u8a3c\u3067\u3059\u3002<\/p>\n<\/div>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-13054 border-3\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2024\/07\/laravel-line-richmenu-017.png\" alt=\"\" width=\"495\" height=\"83\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2024\/07\/laravel-line-richmenu-017.png 495w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2024\/07\/laravel-line-richmenu-017-300x50.png 300w\" sizes=\"auto, (max-width: 495px) 100vw, 495px\" \/><\/p>\n<p>\u3067\u306f\u3001\u53d6\u5f97\u3057\u305f2\u3064\u306eID\u3092<code>.env<\/code>\u306b\u30bb\u30c3\u30c8\u3057\u3066\u304a\u304d\u307e\u3057\u3087\u3046\u3002<\/p>\n<p><strong>.env<\/strong><\/p>\n<div>\n<pre><strong>RICH_MENU_ID_1=\"richmenu-********************************\"<\/strong>\r\n<strong>RICH_MENU_ID_2=\"richmenu-********************************\"<\/strong><\/pre>\n<\/div>\n<\/div>\n<div>\n<h2>Enum\uff08\u5217\u6319\u578b\uff09\u3067\u30ea\u30c3\u30c1\u30e1\u30cb\u30e5\u30fc\u306e\u7a2e\u985e\u3092\u5b9a\u7fa9\u3059\u308b<\/h2>\n<\/div>\n<p>\u4eca\u56de\u306f2\u7a2e\u985e\u306e\u30ea\u30c3\u30c1\u30e1\u30cb\u30e5\u30fc\u3092\u5207\u308a\u66ff\u3048\u307e\u3059\u306e\u3067\u3001\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3057\u3084\u3059\u3044\u3088\u3046\u306b<code>Enum<\/code>\u3092\u3064\u304f\u3063\u3066\u304a\u304d\u307e\u3057\u3087\u3046\u3002<\/p>\n<p>\u203b<code>Enum<\/code>\u306e\u8a73\u3057\u3044\u8aac\u660e\u306f\u4ee5\u4e0b\u30da\u30fc\u30b8\u3092\u3054\u89a7\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>\ud83d\udcdd\u00a0<a href=\"https:\/\/blog.capilano-fw.com\/?p=9829\" target=\"_blank\" rel=\"noopener\">\u3010Laravel\u3011PHP 8.1 \u304b\u3089\u4f7f\u3048\u308b Enum\u3067\u3001\u9078\u629e\u80a2\u301c\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u307e\u3067\u5b9f\u88c5\u3057\u3066\u307f\u308b<\/a><\/p>\n<p><strong>app\/Enums\/RichMenuType.php<\/strong><\/p>\n<div>\n<pre><strong>&lt;?php<\/strong>\r\n\r\n<strong>namespace App\\Enums;<\/strong>\r\n\r\n<strong>enum RichMenuType: string<\/strong>\r\n<strong>{<\/strong>\r\n<strong>    case RichMenu1 = 'rich-menu-1';<\/strong>\r\n<strong>    case RichMenu2 = 'rich-menu-2';<\/strong>\r\n\r\n<strong>    public function id(): string<\/strong>\r\n<strong>    {<\/strong>\r\n<strong>        return match ($this) {<\/strong>\r\n<strong>            self::RichMenu1 =&gt; env('RICH_MENU_ID_1'),<\/strong>\r\n<strong>            self::RichMenu2 =&gt; env('RICH_MENU_ID_2'),<\/strong>\r\n<strong>        };<\/strong>\r\n<strong>    }<\/strong>\r\n<strong>}<\/strong><\/pre>\n<\/div>\n<div>\n<h2>\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u3067\u30a6\u30a7\u30d6\u30d5\u30c3\u30af\u3092\u3064\u304f\u308a\u3001\u30ea\u30c3\u30c1\u30e1\u30cb\u30e5\u30fc\u3092\u64cd\u4f5c\u3059\u308b<\/h2>\n<p>\u30a6\u30a7\u30d6\u30d5\u30c3\u30af\u6709\u52b9\u306b\u3059\u308b\u3068\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u64cd\u4f5c\u304c\u3042\u3063\u305f\u3068\u304d\u306b<code>Laravel<\/code>\u5074\u3078\u901a\u77e5\u3092\u3057\u3066\u304f\u308c\u307e\u3059\u3002<\/p>\n<ul>\n<li>\u53cb\u3060\u3061\u767b\u9332\u3057\u305f\u3068\u304d<\/li>\n<li>\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u53d7\u4fe1\u3057\u305f\u3068\u304d<\/li>\n<li>\u753b\u50cf\u304c\u9001\u4fe1\u3055\u308c\u305f\u3068\u304d<\/li>\n<\/ul>\n<p>\u3053\u306e\u30a6\u30a7\u30d6\u30d5\u30c3\u30af\u3092<code>Laravel<\/code>\u3067\u4f5c\u3063\u3066\u3044\u304d\u307e\u3059\u3002<br \/>\n\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<\/div>\n<div>\n<pre><strong>php artisan make:controller LineRichMenuWebhookController<\/strong><\/pre>\n<p>\u30d5\u30a1\u30a4\u30eb\u304c\u4f5c\u6210\u3055\u308c\u308b\u306e\u3067\u3001\u4e2d\u8eab\u3092\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u5909\u66f4\u3057\u307e\u3059\u3002<\/p>\n<p><strong>app\/Http\/Controllers\/LineRichMenuWebhookController.php<\/strong><\/p>\n<div>\n<pre><strong>&lt;?php<\/strong>\r\n\r\n<strong>namespace App\\Http\\Controllers;<\/strong>\r\n\r\n<strong>use App\\Enums\\RichMenuType;<\/strong>\r\n<strong>use App\\Models\\LineUser;<\/strong>\r\n<strong>use GuzzleHttp\\Client as GuzzleClient;<\/strong>\r\n<strong>use Illuminate\\Http\\Request;<\/strong>\r\n<strong>use LINE\\Clients\\MessagingApi\\Configuration;<\/strong>\r\n<strong>use LINE\\Clients\\MessagingApi\\Api\\MessagingApiApi;<\/strong>\r\n<strong>use LINE\\Clients\\MessagingApi\\Model\\TextMessage;<\/strong>\r\n<strong>use LINE\\Clients\\MessagingApi\\Model\\Message;<\/strong>\r\n<strong>use LINE\\Clients\\MessagingApi\\Model\\ReplyMessageRequest;<\/strong>\r\n<strong>use LINE\\Constants\\MessageType;<\/strong>\r\n<strong>use LINE\\Parser\\EventRequestParser;<\/strong>\r\n<strong>use LINE\\Webhook\\Model\\FollowEvent;<\/strong>\r\n<strong>use LINE\\Webhook\\Model\\PostbackEvent;<\/strong>\r\n\r\n<strong>class LineRichMenuWebhookController extends Controller<\/strong>\r\n<strong>{<\/strong>\r\n<strong>    public function __construct()<\/strong>\r\n<strong>    {<\/strong>\r\n<strong>        \/\/ \u672c\u6765\u306f config \u304b\u3089\u53d6\u5f97\u3059\u308b\u3079\u304d\u3067\u3059<\/strong>\r\n<strong>        $this-&gt;channel_secret = env('LINE_CHANNEL_SECRET');<\/strong>\r\n<strong>        $this-&gt;access_token = env('LINE_ACCESS_TOKEN');<\/strong>\r\n<strong>    }<\/strong>\r\n\r\n<strong>    public function receive(Request $request): void<\/strong>\r\n<strong>    {<\/strong>\r\n<strong>        $request_body = $request-&gt;getContent();<\/strong>\r\n<strong>        $hash = hash_hmac('sha256', $request_body, $this-&gt;channel_secret, true);<\/strong>\r\n<strong>        $signature = base64_encode($hash);<\/strong>\r\n\r\n<strong>        if($signature === $request-&gt;header('X-Line-Signature')) {<\/strong>\r\n\r\n<strong>            $client = new GuzzleClient;<\/strong>\r\n<strong>            $config = new Configuration();<\/strong>\r\n<strong>            $config-&gt;setAccessToken($this-&gt;access_token);<\/strong>\r\n\r\n<strong>            $this-&gt;api = new MessagingApiApi(<\/strong>\r\n<strong>                client: $client,<\/strong>\r\n<strong>                config: $config,<\/strong>\r\n<strong>            );<\/strong>\r\n\r\n<strong>            try {<\/strong>\r\n\r\n<strong>                $event_parser = EventRequestParser::parseEventRequest($request_body, $this-&gt;channel_secret, $signature);<\/strong>\r\n\r\n<strong>                foreach($event_parser-&gt;getEvents() as $event) {<\/strong>\r\n\r\n<strong>                    if($event instanceof FollowEvent) { \/\/ \u304a\u53cb\u3060\u3061\u767b\u9332\u3057\u305f\u3068\u304d<\/strong>\r\n\r\n<strong>                        $this-&gt;onFollow($event);<\/strong>\r\n\r\n<strong>                    } else if($event instanceof PostbackEvent) { \/\/ \u30dd\u30b9\u30c8\u30d0\u30c3\u30af\uff1a\u30ea\u30c3\u30c1\u30e1\u30cb\u30e5\u30fc\u304c\u30bf\u30c3\u30d7\u3055\u308c\u305f\u3068\u304d<\/strong>\r\n\r\n<strong>                        $this-&gt;onPostback($event);<\/strong>\r\n\r\n<strong>                    }<\/strong>\r\n\r\n<strong>                }<\/strong>\r\n\r\n<strong>            } catch (\\Exception $e) {<\/strong>\r\n\r\n<strong>                logger()-&gt;error($e-&gt;getMessage());<\/strong>\r\n\r\n<strong>            }<\/strong>\r\n\r\n<strong>        } else {<\/strong>\r\n\r\n<strong>            abort(404);<\/strong>\r\n\r\n<strong>        }<\/strong>\r\n<strong>    }<\/strong>\r\n\r\n<strong>    private function onFollow(FollowEvent $event): void<\/strong>\r\n<strong>    {<\/strong>\r\n<strong>        $reply_token = $event-&gt;getReplyToken();<\/strong>\r\n<strong>        $line_id = $event-&gt;getSource()-&gt;getUserId();<\/strong>\r\n<strong>        $mode = $event-&gt;getMode();<\/strong>\r\n<strong>        $profile = $this-&gt;api-&gt;getProfile($line_id);<\/strong>\r\n<strong>        $display_name = $profile-&gt;getDisplayName();<\/strong>\r\n\r\n<strong>        $line_user = LineUser::firstOrNew(['line_id' =&gt; $line_id]);<\/strong>\r\n<strong>        $line_user-&gt;display_name = $display_name;<\/strong>\r\n<strong>        $line_user-&gt;mode = $mode;<\/strong>\r\n<strong>        $line_user-&gt;rich_menu_type = RichMenuType::RichMenu1;<\/strong>\r\n<strong>        $line_user-&gt;save();<\/strong>\r\n\r\n<strong>        $message = new TextMessage([<\/strong>\r\n<strong>            'type' =&gt; MessageType::TEXT,<\/strong>\r\n<strong>            'text' =&gt; '\u53cb\u3060\u3061\u767b\u9332\u3042\u308a\u304c\u3068\u3046\u3054\u3056\u3044\u307e\u3059\uff01',<\/strong>\r\n<strong>        ]);<\/strong>\r\n\r\n<strong>        $this-&gt;replyMessage($reply_token, $message);<\/strong>\r\n\r\n<strong>        $this-&gt;setRichMenu($line_id, RichMenuType::RichMenu1);<\/strong>\r\n<strong>    }<\/strong>\r\n\r\n<strong>    private function onPostback(PostbackEvent $event): void<\/strong>\r\n<strong>    {<\/strong>\r\n<strong>        $line_id = $event-&gt;getSource()-&gt;getUserId();<\/strong>\r\n<strong>        $data = $event-&gt;getPostback()-&gt;getData();<\/strong>\r\n<strong>        parse_str($data, $parsed_data);<\/strong>\r\n\r\n<strong>        $action = data_get($parsed_data, 'action');<\/strong>\r\n\r\n<strong>        if($action === 'switch_rich_menu') {<\/strong>\r\n\r\n<strong>            $line_user = LineUser::where('line_id', $line_id)-&gt;first();<\/strong>\r\n\r\n<strong>            if(! is_null($line_user)) {<\/strong>\r\n\r\n<strong>                $rich_menu_type = ($line_user-&gt;rich_menu_type === RichMenuType::RichMenu1-&gt;value)<\/strong>\r\n<strong>                    ? RichMenuType::RichMenu2<\/strong>\r\n<strong>                    : RichMenuType::RichMenu1;<\/strong>\r\n<strong>                $line_user-&gt;rich_menu_type = $rich_menu_type-&gt;value;<\/strong>\r\n<strong>                $line_user-&gt;save();<\/strong>\r\n\r\n<strong>                $this-&gt;setRichMenu($line_id, $rich_menu_type);<\/strong>\r\n\r\n<strong>            }<\/strong>\r\n\r\n<strong>        }<\/strong>\r\n<strong>    }<\/strong>\r\n\r\n<strong>    private function replyMessage(string $reply_token, Message $message): bool<\/strong>\r\n<strong>    {<\/strong>\r\n<strong>        try {<\/strong>\r\n\r\n<strong>            $request = new ReplyMessageRequest([<\/strong>\r\n<strong>                'replyToken' =&gt; $reply_token,<\/strong>\r\n<strong>                'messages' =&gt; [$message],<\/strong>\r\n<strong>            ]);<\/strong>\r\n<strong>            $this-&gt;api-&gt;replyMessage($request);<\/strong>\r\n<strong>            return true;<\/strong>\r\n\r\n<strong>        } catch (\\Exception $e) {<\/strong>\r\n\r\n<strong>            logger()-&gt;error($e-&gt;getMessage());<\/strong>\r\n\r\n<strong>        }<\/strong>\r\n\r\n<strong>        return false;<\/strong>\r\n<strong>    }<\/strong>\r\n\r\n<strong>    private function setRichMenu(string $line_id, RichMenuType $rich_menu_type): void<\/strong>\r\n<strong>    {<\/strong>\r\n<strong>        $rich_menu_id = $rich_menu_type-&gt;id();<\/strong>\r\n\r\n<strong>        try {<\/strong>\r\n\r\n<strong>            $this-&gt;api-&gt;linkRichMenuIdToUser($line_id, $rich_menu_id);<\/strong>\r\n\r\n<strong>        } catch (\\Exception $e) {<\/strong>\r\n\r\n<strong>            logger()-&gt;error($e-&gt;getMessage());<\/strong>\r\n\r\n<strong>        }<\/strong>\r\n<strong>    }<\/strong>\r\n<strong>}<\/strong><\/pre>\n<h2>\u30ea\u30c3\u30c1\u30e1\u30cb\u30e5\u30fc\u3092\u64cd\u4f5c\u3059\u308b\u305f\u3081\u306e\u30a6\u30a7\u30d6\u30d5\u30c3\u30af\u306e\u30eb\u30fc\u30c8\u3092\u3064\u304f\u308b<\/h2>\n<p>\u6700\u5f8c\u306b\u30eb\u30fc\u30c8\u3067\u3059\u3002<\/p>\n<p><strong>routes\/web.php<\/strong><\/p>\n<\/div>\n<div>\n<pre>\/\/ \u7701\u7565\r\n\r\n<strong>use App\\Http\\Controllers\\LineRichMenuWebhookController;<\/strong>\r\n\r\n\/\/ \u7701\u7565\r\n\r\n\/\/ LINE rich menu\r\n<strong>Route::prefix('line_rich_menu')-&gt;group(function(){<\/strong>\r\n\r\n<strong>    Route::prefix('webhook')-&gt;controller(LineRichMenuWebhookController::class)-&gt;group(function(){<\/strong>\r\n\r\n<strong>        Route::post('receive', 'receive')-&gt;name('line_marketing.receive');<\/strong>\r\n\r\n<strong>    });<\/strong>\r\n\r\n<strong>});<\/strong>\r\n\r\n\/\/ \u7701\u7565<\/pre>\n<p>\u3053\u308c\u3067\u4f5c\u696d\u306f\u5b8c\u4e86\u3067\u3059\uff01<br \/>\n\u304a\u75b2\u308c\u69d8\u3067\u3057\u305f\ud83d\ude0a<\/p>\n<h2>\u5b9f\u969b\u306bLINE\u306e\u30ea\u30c3\u30c1\u30e1\u30cb\u30e5\u30fc\u304c\u5207\u308a\u66ff\u308f\u308b\u304b\u30c6\u30b9\u30c8\u3057\u3066\u307f\u308b<\/h2>\n<p>\u30c6\u30b9\u30c8\u306e\u624b\u9806\u306f\u6b21\u306e\u3068\u304a\u308a\u3067\u3059\u3002<\/p>\n<ol>\n<li>LINE\u306eQR\u30b3\u30fc\u30c9\u3092\u4f7f\u3063\u3066\u53cb\u3060\u3061\u767b\u9332\u3059\u308b<\/li>\n<li>\u30e1\u30cb\u30e5\u30fc\u304c\u8868\u793a\u3055\u308c\u3066\u3044\u308b\u304b\u78ba\u8a8d<\/li>\n<li>\u5de6\u5074\u30a8\u30ea\u30a2\u3092\u30bf\u30c3\u30d7\u3057\u3066\u300c\u4eca\u304c\u3069\u3063\u3061\u306e\u30ea\u30c3\u30c1\u30e1\u30cb\u30e5\u30fc\u304b\u300d\u78ba\u8a8d<\/li>\n<li>\u53f3\u5074\u30a8\u30ea\u30a2\u3092\u30bf\u30c3\u30d7\u3057\u3066\u30ea\u30c3\u30c1\u30e1\u30cb\u30e5\u30fc\u5207\u308a\u66ff\u3048<\/li>\n<li>\u518d\u5ea6\u3001\u5de6\u5074\u30a8\u30ea\u30a2\u3092\u30bf\u30c3\u30d7\u3057\u3066\u300c\u3069\u3063\u3061\u306e\u30ea\u30c3\u30c1\u30e1\u30cb\u30e5\u30fc\u304b\u300d\u78ba\u8a8d<\/li>\n<\/ol>\n<p>\u3067\u306f\u3001\u53cb\u3060\u3061\u767b\u9332\u3057\u3066\u30e1\u30cb\u30e5\u30fc\u3092\u898b\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<\/div>\n<\/div>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-13057 border-3\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2024\/07\/laravel-line-richmenu-019.png\" alt=\"\" width=\"640\" height=\"380\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2024\/07\/laravel-line-richmenu-019.png 640w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2024\/07\/laravel-line-richmenu-019-300x178.png 300w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/p>\n<p>\u767b\u9332\u304c\u5b8c\u4e86\u3057\u3066\u30fb\u30fb\u30fb\u30fb\u30fb\u30fb<\/p>\n<div>\n<div>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-13056 border-3\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2024\/07\/laravel-line-richmenu-018.png\" alt=\"\" width=\"640\" height=\"339\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2024\/07\/laravel-line-richmenu-018.png 640w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2024\/07\/laravel-line-richmenu-018-300x159.png 300w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/p>\n<p>\u306f\u3044\uff01<br \/>\n\u753b\u9762\u4e0b\u90e8\u306b\u30ea\u30c3\u30c1\u30e1\u30cb\u30e5\u30fc\u304c\u8868\u793a\u3055\u308c\u307e\u3057\u305f\u3002<\/p>\n<p>\u3067\u306f\u3001\u5de6\u5074\u30a8\u30ea\u30a2\uff08A\uff09\u3092\u30bf\u30c3\u30d7\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<p>\u3069\u3046\u306a\u308b\u3067\u3057\u3087\u3046\u304b\u30fb\u30fb\u30fb\u30fb\u30fb\u30fb<\/p>\n<\/div>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-13058 border-3\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2024\/07\/laravel-line-richmenu-020.png\" alt=\"\" width=\"640\" height=\"298\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2024\/07\/laravel-line-richmenu-020.png 640w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2024\/07\/laravel-line-richmenu-020-300x140.png 300w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/p>\n<p>\u306f\u3044\uff01<br \/>\n\u307e\u305a\u306f\u73fe\u5728\u304c\u300c\u30ea\u30c3\u30c1\u30e1\u30cb\u30e5\u30fc1\u300d\u3067\u3042\u308b\u3053\u3068\u304c\u308f\u304b\u308a\u307e\u3057\u305f\u3002<\/p>\n<p>\u3067\u306f\u3001\u53f3\u5074\u90e8\u5206\uff08B\uff09\u3092\u30bf\u30c3\u30d7\u3057\u3066\u3001\u30ea\u30c3\u30c1\u30e1\u30cb\u30e5\u30fc\u3092\u5207\u308a\u66ff\u3048\u3001\u540c\u3058\u304f\u30ea\u30c3\u30c1\u30e1\u30cb\u30e5\u30fc2\u306e\uff08A\uff09\u90e8\u5206\u3092\u30bf\u30c3\u30d7\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<p>\u3046\u307e\u304f\u3044\u304f\u3067\u3057\u3087\u3046\u304b\u30fb\u30fb\u30fb\u30fb\u30fb\u30fb<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-13059 border-3\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2024\/07\/laravel-line-richmenu-021.png\" alt=\"\" width=\"640\" height=\"407\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2024\/07\/laravel-line-richmenu-021.png 640w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2024\/07\/laravel-line-richmenu-021-300x191.png 300w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/p>\n<p>\u306f\u3044\uff01<br \/>\n\u73fe\u5728\u304c\u30ea\u30c3\u30c1\u30e1\u30cb\u30e5\u30fc2\u3067\u3042\u308b\u3053\u3068\u304c\u308f\u304b\u308a\u307e\u3059\u3002<\/p>\n<p>\u3059\u3079\u3066\u6210\u529f\u3067\u3059\ud83d\ude0a\u2728<\/p>\n<p>\u203b\u4eca\u56de\u306f\u540c\u3058\u753b\u50cf\u3092\u4f7f\u3063\u305f\u306e\u3067\u898b\u305f\u76ee\u306b\u5909\u5316\u306f\u3042\u308a\u307e\u305b\u3093\u304c\u3001\u3082\u3061\u308d\u3093\u5225\u306e\u753b\u50cf\u3092\u4f7f\u3046\u3053\u3068\u3082\u3067\u304d\u308b\u306e\u3067\u3001\u5168\u304f\u9055\u3063\u305f\u30ea\u30c3\u30c1\u30e1\u30cb\u30e5\u30fc\u306b\u5207\u308a\u66ff\u3048\u308b\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3088\uff01<\/p>\n<h2>\u30ea\u30c3\u30c1\u30e1\u30cb\u30e5\u30fc\u3092\u6d3b\u7528\u3057\u305f\u3044\u4f01\u696d\u69d8\u3078\u306e\u3054\u63d0\u6848<\/h2>\n<p><code>LINE<\/code>\u304c\u30e1\u30c3\u30bb\u30fc\u30b8\u30a2\u30d7\u30ea\u3060\u3051\u3067\u306a\u304f\u3001\u30de\u30fc\u30b1\u30c6\u30a3\u30f3\u30b0\u30fb\u30c4\u30fc\u30eb\u3068\u3057\u3066\u5229\u7528\u3055\u308c\u308b\u3053\u3068\u306f\u73cd\u3057\u304f\u306a\u304f\u306a\u308a\u307e\u3057\u305f\u3002<\/p>\n<p>\u4eca\u56de\u306e\u3088\u3046\u306b\u30ea\u30c3\u30c1\u30e1\u30cb\u30e5\u30fc\u3092\u5207\u308a\u66ff\u3048\u308b\u3053\u3068\u3067\u3001\u3088\u308a\u898b\u8fbc\u307f\u5ba2\u3078\u306e\u300c\u4fa1\u5024\u89b3\u6559\u80b2\u300d\u3092\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p><mark>\u307e\u305f\u3001<strong>LINE\u306e\u30e1\u30c3\u30bb\u30fc\u30b8\u958b\u5c01\u7387\u3084\u30ea\u30f3\u30af\u30af\u30ea\u30c3\u30af\u7387\u306f\u3001\u30e1\u30eb\u30de\u30ac\u3068\u6bd4\u3079\u3066\u3082\u683c\u6bb5\u306b\u591a\u3044<\/strong>\u3053\u3068\u304c\u308f\u304b\u3063\u3066\u3044\u307e\u3059\u3002<\/mark><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-13060\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2024\/07\/laravel-line-richmenu-022.png\" alt=\"\" width=\"640\" height=\"360\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2024\/07\/laravel-line-richmenu-022.png 640w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2024\/07\/laravel-line-richmenu-022-300x169.png 300w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/p>\n<p><small>\u753b\u50cf\uff1a<a href=\"https:\/\/linestep.jp\/lp\/01\/comparison.html\" target=\"_blank\" rel=\"noopener\">\u30e1\u30eb\u30de\u30ac\u30fbLINE\u516c\u5f0f\u30a2\u30ab\u30a6\u30f3\u30c8(*)\u30fbL\u30b9\u30c6\u30c3\u30d7\u306e\u6bd4\u8f03<\/a><\/small><\/p>\n<\/div>\n<p>\u3082\u3057<code>LINE<\/code>\u3092\u4f7f\u3063\u305f\u65bd\u7b56\u3092\u3054\u5e0c\u671b\u3067\u3057\u305f\u3089\u3001\u305c\u3072\u304a\u554f\u3044\u5408\u308f\u305b\u304b\u3089\u3054\u9023\u7d61\u304f\u3060\u3055\u3044\u3002\u304a\u5f85\u3061\u3057\u3066\u304a\u308a\u307e\u3059\u3002\ud83d\ude0a\u2728<\/p>\n<h2>\u304a\u308f\u308a\u306b<\/h2>\n<p>\u3068\u3044\u3046\u3053\u3068\u3067\u3001\u4eca\u56de\u306f<code>Laravel<\/code>\u3067<code>LINE<\/code>\u306e\u30ea\u30c3\u30c1\u30e1\u30cb\u30e5\u30fc\u5207\u308a\u66ff\u3048\u3092\u5b9f\u88c5\u3057\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n<p>\u3061\u306a\u307f\u306b\u3001<code>LINE<\/code>\u306e<code>composer<\/code>\u30d1\u30c3\u30b1\u30fc\u30b8\u304c\u65b0\u3057\u304f\u306a\u3063\u3066\u304b\u3089\u6bce\u56de\u306a\u306e\u3067\u3059\u304c\u3001\u60c5\u5831\u304c\u5c11\u306a\u3059\u304e\u3066\u30e1\u30bd\u30c3\u30c9\u306f\u3069\u308c\u3092\u4f7f\u3048\u3070\u3044\u3044\u304b\u308f\u304b\u3089\u306a\u3044\u3093\u3067\u3059\u3088\u306d\u2026\u3002<\/p>\n<p>\u306a\u306e\u3067\u3001\u3044\u3063\u305d\u306e\u3053\u3068\u30d1\u30c3\u30b1\u30fc\u30b8\u306a\u3093\u304b\u4f7f\u308f\u305a\u306b<code>HTTP<\/code>\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u3092\u4f7f\u3063\u305f\u3068\u3053\u308d\u30b9\u30f3\u30ca\u30ea\u3044\u304d\u307e\u3057\u305f\uff08\u7b11\uff09<\/p>\n<p>\u4eca\u5f8c\u306f<code>LINE Messaging API<\/code>\u4f7f\u3046\u3068\u304d\u306f\u3082\u3046\u30d1\u30c3\u30b1\u30fc\u30b8\u306f\u4f7f\u308f\u306a\u3044\u304b\u3082\u3057\u308c\u307e\u305b\u3093\uff08\u308f\u308a\u3068\u672c\u6c17\uff01\uff09<\/p>\n<p>\u305c\u3072\u7686\u3055\u3093\u3082\u8a66\u3057\u3066\u307f\u3066\u304f\u3060\u3055\u3044\u306d\u3002<\/p>\n<p>\u3067\u306f\u3067\u306f\u301c\uff01<\/p>\n<p style=\"text-align: center;\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-10758 aligncenter\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2022\/06\/no_21.png\" alt=\"\" width=\"370\" height=\"320\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2022\/06\/no_21.png 370w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2022\/06\/no_21-300x259.png 300w\" sizes=\"auto, (max-width: 370px) 100vw, 370px\" \/>\u300c\u3044\u3084\u3001\u591c\u4e2d3\u6642\u3067<br \/>\n\u6c17\u6e2928\u5ea6\u3063\u3066<br \/>\n\u7f70\u30b2\u30fc\u30e0\u3067\u3059\u304b\u2026\ud83d\ude2b\u300d<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3055\u3066\u3055\u3066\u3001\u3054\u5b58\u77e5\u306e\u300cLINE\u300d\u304c\u30e1\u30c3\u30bb\u30fc\u30b8\u30a2\u30d7\u30ea\u3060\u3051\u3058\u3083\u306a\u304f\u3001\u30d3\u30b8\u30cd\u30b9\u3067\u3082\u91cd\u8981\u306a\u306e\u3092\u3054\u5b58\u77e5\u3067\u3057\u3087\u3046\u304b\u3002\u306a\u305c\u306a\u3089\u3001 9,500\u4e07\u4eba\u3068\u3044\u3046\u5727\u5012\u7684\u306a\u30e6\u30fc\u30b6\u30fc\u304c\u3044\u308b\u304b\u3089 &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/blog.capilano-fw.com\/?p=13013\" class=\"more-link\"><span class=\"screen-reader-text\">&#8220;Laravel\u3067LINE\u306e\u30ea\u30c3\u30c1\u30e1\u30cb\u30e5\u30fc\uff08\u5207\u308a\u66ff\u3048\u53ef\uff09\u3092\u3064\u304f\u308b&#8221; \u306e<\/span>\u7d9a\u304d\u3092\u8aad\u3080<\/a><\/p>\n","protected":false},"author":1,"featured_media":13069,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,258],"tags":[],"class_list":["post-13013","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-laravel","category-258"],"_links":{"self":[{"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts\/13013","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=13013"}],"version-history":[{"count":25,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts\/13013\/revisions"}],"predecessor-version":[{"id":13070,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts\/13013\/revisions\/13070"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/media\/13069"}],"wp:attachment":[{"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=13013"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=13013"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=13013"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}