pharit/laravel-line-api 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

pharit/laravel-line-api

Composer 安装命令:

composer require pharit/laravel-line-api

包简介

A Laravel package for LINE Messaging API (push, reply, multicast, signature verification).

README 文档

README

A lightweight Laravel package for LINE Messaging API: push, reply, multicast, broadcast, profile lookup, and webhook signature verification.

Install (local path)

  1. Add to your app's composer.json repositories:
"repositories": [
  {
    "type": "path",
    "url": "../laravel-line-api",
    "options": { "symlink": true }
  }
]
  1. Require the package in your app:
composer require iaa/laravel-line-api:dev-main
  1. Publish config:
php artisan vendor:publish --tag=config --provider="Pharit\\LaravelLineApi\\LaravelLineApiServiceProvider"
  1. Set env vars:
LINE_CHANNEL_ACCESS_TOKEN=your_channel_access_token
LINE_CHANNEL_SECRET=your_channel_secret

Usage

use Pharit\\LaravelLineApi\\Facades\\Line;

// Reply
Line::reply($replyToken, [
    Line::textMessage('Hello!'),
]);

// Push
Line::push($userId, [
    ['type' => 'text', 'text' => 'Update available'],
]);

// Multicast
Line::multicast([$userId1, $userId2], [
    ['type' => 'text', 'text' => 'Hello all'],
]);

// Broadcast
Line::broadcast([
    ['type' => 'text', 'text' => 'System maintenance 10pm'],
]);

// Profile
$profile = Line::getProfile($userId)->json();

Rich menu

use Pharit\\LaravelLineApi\\Facades\\Line;

// Create
$response = Line::createRichMenu([
    'size' => ['width' => 2500, 'height' => 843],
    'selected' => false,
    'name' => 'My Menu',
    'chatBarText' => 'Tap here',
    'areas' => [
        [
            'bounds' => ['x' => 0, 'y' => 0, 'width' => 1250, 'height' => 843],
            'action' => ['type' => 'message', 'text' => 'Hello'],
        ],
        [
            'bounds' => ['x' => 1250, 'y' => 0, 'width' => 1250, 'height' => 843],
            'action' => ['type' => 'uri', 'uri' => 'https://example.com'],
        ],
    ],
]);
$richMenuId = $response->json('richMenuId');

// Upload image (path). Content-Type auto-detected from extension
Line::uploadRichMenuImage($richMenuId, storage_path('app/menu.png'));

// Link to a user
Line::linkRichMenuToUser($userId, $richMenuId);

// Set as default for all users
Line::setDefaultRichMenu($richMenuId);

// List
$list = Line::getRichMenuList()->json('richmenus');

Verify webhook signatures

Add middleware to your webhook route to validate X-Line-Signature:

use Pharit\\LaravelLineApi\\Http\\Middleware\\VerifyLineSignature;

Route::post('/line/webhook', Controller::class)
    ->middleware(VerifyLineSignature::class);

Disable via LINE_VERIFY_SIGNATURE=false if needed.

Configuration

See config/line.php after publish.

License

MIT

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-08-11