diff --git a/lib/XmppPrebind.php b/lib/XmppPrebind.php index 8110ba7..f9323c1 100644 --- a/lib/XmppPrebind.php +++ b/lib/XmppPrebind.php @@ -133,7 +133,12 @@ public function connect($username, $password) { $this->sid = $body->getAttribute('sid'); $this->debug($this->sid, 'sid'); - $mechanisms = $body->firstChild->firstChild->getElementsByTagName('mechanism'); + $child = $body->firstChild->firstChild; + if (is_object($child)) { + $mechanisms = $child->getElementsByTagName('mechanism'); + } else { + throw new Exception('Invalid response'); + } foreach ($mechanisms as $value) { $this->mechanisms[] = $value->nodeValue; @@ -617,4 +622,4 @@ protected function getAndIncrementRid() { */ class XmppPrebindException extends Exception{} -class XmppPrebindConnectionException extends XmppPrebindException {} \ No newline at end of file +class XmppPrebindConnectionException extends XmppPrebindException {}