定制 tourze/wechat-work-jssdk-bundle 二次开发

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

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

tourze/wechat-work-jssdk-bundle

最新稳定版本:0.1.2

Composer 安装命令:

composer require tourze/wechat-work-jssdk-bundle

包简介

企业微信JSSDK集成包,提供企业微信应用的JavaScript SDK功能

README 文档

README

English | 中文

Latest Version License Build Status Quality Score Code Coverage Total Downloads

A Symfony bundle that provides WeChat Work (Enterprise WeChat) JSSDK integration with configuration generation, signature verification, and semantic annotation support.

Features

  • JSSDK Configuration Generation: Generate WeChat Work JSSDK configuration with proper signature verification
  • JSON-RPC API: Expose JSSDK configuration through JSON-RPC endpoints
  • Semantic Annotations: Support for semantic tags like phone numbers, emails, red packets
  • Test Interface: Built-in test controller for JSSDK functionality verification
  • Ticket Management: Automatic handling of corp and agent JS API tickets
  • Symfony Integration: Full integration with Symfony framework and dependency injection

Installation

composer require tourze/wechat-work-jssdk-bundle

Quick Start

1. Basic Configuration

Add the bundle to your config/bundles.php:

<?php

return [
    // ... other bundles
    WechatWorkJssdkBundle\WechatWorkJssdkBundle::class => ['all' => true],
];

2. Generate JSSDK Configuration

The bundle provides a JSON-RPC procedure to generate JSSDK configuration:

<?php

use WechatWorkJssdkBundle\Procedure\GetWechatWorkJssdkConfig;

// Via JSON-RPC call
$config = $jsonRpcClient->call('GetWechatWorkJssdkConfig', [
    'corpId' => 'your-corp-id',
    'agentId' => 'your-agent-id',
    'url' => 'https://your-domain.com/current-page'
]);

// Returns:
// [
//     'corp' => [
//         'beta' => true,
//         'appId' => 'corp-id',
//         'timestamp' => 1234567890,
//         'nonceStr' => 'random-string',
//         'signature' => 'generated-signature'
//     ],
//     'agent' => [
//         'corpid' => 'corp-id',
//         'agentid' => 'agent-id',
//         'timestamp' => 1234567890,
//         'nonceStr' => 'random-string',
//         'signature' => 'generated-signature'
//     ]
// ]

3. Frontend Integration

Use the generated configuration in your frontend:

// Configure WeChat Work JSSDK
wx.config({
    beta: config.corp.beta,
    debug: false,
    appId: config.corp.appId,
    timestamp: config.corp.timestamp,
    nonceStr: config.corp.nonceStr,
    signature: config.corp.signature,
    jsApiList: ['getCurExternalContact', 'selectExternalContact']
});

// Configure agent-specific features
wx.agentConfig({
    corpid: config.agent.corpid,
    agentid: config.agent.agentid,
    timestamp: config.agent.timestamp,
    nonceStr: config.agent.nonceStr,
    signature: config.agent.signature,
    jsApiList: ['getCurExternalContact', 'selectExternalContact']
});

4. Test Interface

Access the test interface at /wechat/work/test/jssdk to verify JSSDK functionality.

API Reference

JSON-RPC Procedures

GetWechatWorkJssdkConfig

Generate JSSDK configuration for WeChat Work integration.

Parameters:

  • corpId (string): Enterprise ID
  • agentId (string): Application ID
  • url (string): Current page URL (without # and following parts)

Returns:

  • corp (array): Corporation-level configuration
  • agent (array): Agent-level configuration

Semantic Annotations

The bundle supports semantic annotations for common data types:

  • EmailAddress: Email address validation and formatting
  • PhoneNumber: Phone number validation and formatting
  • RedPacket: Red packet related semantics

Requirements

  • PHP 8.1 or higher
  • Symfony 6.4 or higher
  • WeChat Work Bundle (tourze/wechat-work-bundle)
  • JSON-RPC Core (tourze/json-rpc-core)

Contributing

Please see CONTRIBUTING.md for details.

License

The MIT License (MIT). Please see License File for more information.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-04-23