user169401
user169401

Reputation:

How to send multiple messages with xmpphp

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

Upvotes: 1

Views: 1728

Answers (4)

DanMan
DanMan

Reputation: 11561

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

Upvotes: 0

Tom
Tom

Reputation: 1

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

Upvotes: 0

Ifju
Ifju

Reputation: 11

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.

Upvotes: 1

ian
ian

Reputation: 12335

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?

Upvotes: 0

Related Questions