PHP code example of tourze / wechat-work-app-chat-bundle
1. Go to this page and download the library: Download tourze/wechat-work-app-chat-bundle library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
tourze / wechat-work-app-chat-bundle example snippets
use WechatWorkAppChatBundle\Service\AppChatService;
// Create a new group chat
$appChatService->createAppChat($chatId, $name, $owner, $userList);
// Update group chat information
$appChatService->updateAppChat($appChat);
// Sync group chat information from WeChat Work API
$appChatService->syncAppChat($appChat);
// Sync all unsynced group chats
$appChatService->syncUnsynced();
// Create a text message
$textMessage = new TextMessage();
$textMessage->setChatId('your-chat-id');
$textMessage->setContent('Hello, World!');
$textMessage->setMentionedList(['@all']); // Mention everyone
// Save to database (automatically triggers sending)
$entityManager->persist($textMessage);
$entityManager->flush();
// Send markdown message directly
$messageService->sendMarkdown('your-chat-id', '# Important Notice\n\nPlease check the latest updates.');
// Create a new group chat
$appChat = new AppChat();
$appChat->setChatId('tech-team-001');
$appChat->setName('Tech Team Discussion');
$appChat->setOwner('john.doe');
$appChat->setUserList(['john.doe', 'jane.smith', 'bob.wilson']);
$entityManager->persist($appChat);
$entityManager->flush();
// Sync with WeChat Work API
$appChatService->syncAppChat($appChat);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.