3 // activate full error reporting
4 //error_reporting(E_ALL & E_STRICT);
6 include 'XMPPHP/XMPP.php';
8 #Use XMPPHP_Log::LEVEL_VERBOSE to get more logging for error reports
9 #If this doesn't work, are you running 64-bit PHP with < 5.2.6?
10 $conn = new XMPPHP_XMPP('localhost', 5222, 'radon', 'password', 'xmpphp', 'localhost', $printlog=true, $loglevel=XMPPHP_Log::LEVEL_INFO);
11 $conn->autoSubscribe();
15 while(!$conn->isDisconnected()) {
16 //$payloads = $conn->processUntil();
17 $payloads = $conn->processUntil(array('message', 'presence', 'end_stream', 'session_start', 'subscription_requested'));
19 foreach($payloads as $event) {
23 print "---------------------------------------------------------------------------------\n";
24 print "Message from: {$pl['from']}\n";
25 if($pl['subject']) print "Subject: {$pl['subject']}\n";
26 print $pl['body'] . "\n";
27 print "---------------------------------------------------------------------------------\n";
28 $conn->message($pl['from'], $body="Thanks for sending me \"{$pl['body']}\".", $type=$pl['type']);
29 if($pl['body'] == 'quit') $conn->disconnect();
30 if($pl['body'] == 'break') $conn->send("</end>");
33 print "Presence: {$pl['from']} [{$pl['show']}] {$pl['status']}\n";
36 print "Session Start\n";
38 $conn->presence($status="Cheese!");
43 } catch(XMPPHP_Exception $e) {
44 die($e->getMessage());