定制 instakit/instachat-laravel-sdk 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

instakit/instachat-laravel-sdk

Composer 安装命令:

composer require instakit/instachat-laravel-sdk

包简介

A clean, Laravel-native SDK for the InstaChat service.

README 文档

README

A clean, Laravel-native SDK for integrating with the InstaChat service.

Installation

You can install the package via composer:

composer require instakit/instachat-laravel-sdk

Configuration

Publish the configuration file:

php artisan vendor:publish --tag="instachat-config"

This will create a config/instachat.php file. You can configure it using the following environment variables in your .env:

INSTACHAT_BASE_URL=http://localhost:8005
INSTACHAT_APP_TOKEN=your-s2s-app-token

Basic Usage

User Token Minting (S2S)

Mint a JWT for a specific end-user:

use Instakit\InstachatSdk\Facades\Instachat;

$tokenResponse = Instachat::users()->mintToken(
    extUserId: 'user-123',
    displayName: 'Alice Smith',
    avatarUrl: 'https://avatar.host/alice.jpg' // optional
);

echo $tokenResponse->token; // JWT Token

Room Management

Create direct or group rooms, and manage memberships:

// Create a group room
$room = Instachat::rooms()->create(
    type: 'group',
    members: ['user-123', 'user-456'],
    metadata: ['project_id' => 'abc-789']
);

// Add a member
Instachat::rooms()->addMember($room->roomId, 'user-789');

// Remove a member
Instachat::rooms()->removeMember($room->roomId, 'user-456');

Message History

Retrieve message history with keyset cursor pagination:

$history = Instachat::messages()->list(
    roomId: $roomId,
    cursor: null, // next_cursor string for pagination
    limit: 50
);

foreach ($history->data as $message) {
    echo $message->content;
}

Attachment Uploads

Upload files into a room's context:

$attachment = Instachat::attachments()->upload(
    roomId: $roomId,
    filePath: '/absolute/path/to/document.pdf'
);

echo $attachment->url;

Running Tests

To run the package's integration test suite:

composer install
./vendor/bin/phpunit

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-07-02

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固