If you wanted to send a message to a number of people you can do it with XMPP. Yes, Here I'm going to explain how you can create the chat room on XMPP ejabbered server in PHP.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
<?php class XMPP_CREATE_ROOM { public function createRoom($room_name) { $command = 'create_room'; $params = array( 'host' => "localhost", 'name' => $room_name, 'service' => 'conference.localhost' ); $this->sendRequest($command, $params); } public function sendRequest($command, $params) {$request = xmlrpc_encode_request($command, $params, (array('encoding' => 'utf-8'))); $context = stream_context_create(array('http' => array( 'method' => "POST", 'header' => "User-Agent: XMLRPC::Client mod_xmlrpc\r\n" . "Content-Type: text/xml\r\n" . "Content-Length: " . strlen($request), 'content' => $request ))); // edit RPC server url $RPC_SERVER = 'http://IP:4560/RPC2' $file = file_get_contents($RPC_SERVER , false, $context); $response = xmlrpc_decode($file); if (xmlrpc_is_fault($response)) { trigger_error("xmlrpc: $response[faultString] ($response[faultCode])"); } else { return $response; } } } $room = new XMPP_CREATE_ROOM(); $room->createRoom('room_name'); ?> |