use WechatOfficialAccountMassBundle\Entity\MassTask;
use WechatOfficialAccountMassBundle\Enum\MassType;
// Create a text message task
$task = new MassTask();
$task->setTitle('Daily Newsletter');
$task->setType(MassType::TEXT);
$task->setContent('Hello, this is a mass message!');
$task->setSendTime(new \DateTimeImmutable('+1 hour'));
$task->setValid(true);
// For all users
$task->setTagId(null);
$task->setOpenIds([]);
// For specific tag
$task->setTagId('100');
// For specific users
$task->setOpenIds(['openid1', 'openid2']);
$entityManager->persist($task);
$entityManager->flush();
#[AsCronTask(expression: '* * * * *')]
class SendMassCommand extends Command
use WechatOfficialAccountMassBundle\Entity\MassTask;
use WechatOfficialAccountMassBundle\Enum\MassType;
$task = new MassTask();
$task->setTitle('Voice Announcement');
$task->setType(MassType::VOICE);
$task->setMediaId('your_uploaded_voice_media_id');
$task->setSendTime(new \DateTimeImmutable('+1 hour'));
$task->setValid(true);
$entityManager->persist($task);
$entityManager->flush();
use WechatOfficialAccountBundle\Entity\Account;
use WechatOfficialAccountMassBundle\Entity\MassTask;
// Assuming you have multiple accounts configured
$account = $accountRepository->findOneBy(['name' => 'main_account']);
$task = new MassTask();
$task->setAccount($account);
// ... other task configuration
// Check task status
$task = $taskRepository->find($taskId);
if ($task->isSent()) {
echo "Task sent successfully";
echo "WeChat Task ID: " . $task->getMsgTaskId();
echo "WeChat Data ID: " . $task->getMsgDataId();
}
bash
php bin/console wechat:send-mass
bash
php bin/console wechat:send-mass
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.