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
其他信息
- 授权协议: MIT
- 更新时间: 2026-07-02