如何使用xmpphp发送多条消息

发布于 2024-08-03 22:56:45 字数 838 浏览 1 评论 0原文

正如标题所示,我想将同一条消息发送给多个收件人。我使用 PHP 库 XMPPHP 并使用以下命令发送单个消息:

<?php
include("xmpp.php");
$conn = new XMPP('talk.google.com', 5222, 'username', 'password', 'xmpphp', 'gmail.com', $printlog=False, $loglevel=LOGGING_INFO);
$conn->connect();
$conn->processUntil('session_start');
$conn->message('[email protected]', 'This is a test message!');
$conn->disconnect();
?>

我用以下循环尝试:

$conn->message('[email protected]', 'This is a test message!');

或者使用完整代码的循环。但什么也没发生...

最诚挚的问候,

汉内斯

As the title says, i want to send the same message to multiple recipients. I use the PHP library XMPPHP and send single messages with this:

<?php
include("xmpp.php");
$conn = new XMPP('talk.google.com', 5222, 'username', 'password', 'xmpphp', 'gmail.com', $printlog=False, $loglevel=LOGGING_INFO);
$conn->connect();
$conn->processUntil('session_start');
$conn->message('[email protected]', 'This is a test message!');
$conn->disconnect();
?>

I try it with a loop of this:

$conn->message('[email protected]', 'This is a test message!');

Or a loop with the complete code. But nothing happens...

Best regards,

Hannes

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

公布 2024-08-10 22:56:45

我会使用 $conn->message('[电子邮件受保护]< /a>', '这是一条测试消息!'); 循环中的行。

此行之前的代码建立连接并等待 xmpp 会话启动。

该行后面的代码会断开连接。

I would use the $conn->message('[email protected]', 'This is a test message!'); line in the loop.

The code before this line makes the connection and waits for the xmpp session starting.

The code after this line makes the disconnection.

摘星┃星的人 2024-08-10 22:56:45

也许你需要在disconnect()之后销毁$conn;如果它在循环中,那么在再次使用它之前?

或者给每个 $conn 一个唯一的名称?

Maybe you need to destroy $conn after your disconnect(); before you use it again if its in a loop?

Or give each $conn a unique name?

温柔少女心 2024-08-10 22:56:45

确保[电子邮件受保护](您的发送对象)已[email protected](您发送邮件的帐户)添加为好友。

Make sure that [email protected] (the person you are sending to) has [email protected] (the account you are sending from) added as a friend.

回忆追雨的时光 2024-08-10 22:56:45

服务器对每个时间范围内可以发送的消息数量有限制。如果您循环发送一堆消息,我想您很快就会达到该限制。尝试使用 http://php.net/sleep

Servers have a limit of how many messages you can send per time frame. If you send a bunch of messages in a loop, i presume you'll hit that limit pretty fast. Try with http://php.net/sleep

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文