#!/usr/bin/php Connect(); $w->LoginWithPassword($password); while (true) { $w->PollMessages(); $msgs = $w->GetMessages(); foreach ($msgs as $m) { $time = date("m/d/Y H:i", $m->_attributeHash['t']); $from = str_replace("@s.whatsapp.net", "", $m->_attributeHash['from']); $name = "(unknown)"; $body = ""; foreach ($m->_children as $child) { if ($child->_tag == "body") { $body = $child->_data; } else if ($child->_tag == "notify") { if (isset($child->_attributeHash) && isset($child->_attributeHash['name'])) { $name = $child->_attributeHash['name']; } } } if (!empty($body)) { echo "[$time] From: $from, Name: $name, Message: $body\n"; } if (strtolower($body) == "exit") { exit; } // print_r($m); } } ?>