ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
# Composer 支持自动加载通过Composer安装的各种插件 ### 安装示例 ~~~ composer require php-amqplib ~~~ ### 代码示例 ~~~ <?php namespace Task; use Ctrl\Controller; use PhpAmqpLib\Connection\AMQPStreamConnection; use PhpAmqpLib\Message\AMQPMessage; Class Task extends Controller { public function WechatSendMqBatch($data) { $queue_name=empty($data['queue_name']) ? 'queue.fanout.message.wechatTemplate':$data['queue_name']; $contents=$data['content']; $connection = new AMQPStreamConnection( '127.0.0.1', 5672, 'user','user'); $channel = $connection->channel(); $channel->queue_declare($queue_name, false, true, false, false); foreach ($contents as $content) { if (is_array($content)) { $content = json_encode($content); } $msg = new AMQPMessage($content); $channel->basic_publish($msg, $queue_name, ""); } //关闭连接 $channel->close(); $connection->close(); } } ?> ~~~