如何使用xmpphp发送多条消息
正如标题所示,我想将同一条消息发送给多个收件人。我使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我会使用
$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.
也许你需要在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?
确保[电子邮件受保护](您的发送对象)已[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.
服务器对每个时间范围内可以发送的消息数量有限制。如果您循环发送一堆消息,我想您很快就会达到该限制。尝试使用 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