diff --git a/services/LinkedinOAuthService.php b/services/LinkedinOAuthService.php index bef3249..ecafc58 100644 --- a/services/LinkedinOAuthService.php +++ b/services/LinkedinOAuthService.php @@ -46,16 +46,22 @@ protected function fetchAttributes() { * @return array */ protected function parseInfo($xml) { + /* @var $simplexml SimpleXMLElement */ $simplexml = simplexml_load_string($xml); - $array = json_decode(json_encode($simplexml), TRUE); - - foreach (array_slice($array, 0) as $key => $value) { - if (empty($value)) - $array[$key] = NULL; - elseif (is_array($value)) - $array[$key] = toArray($value); + return $this->xmlToArray($simplexml); + } + + /** + * + * @param SimpleXMLElement $element + * @return array + */ + protected function xmlToArray($element) { + $array = (array)$element; + foreach ($array as $key => $value) { + if (is_object($value)) + $array[$key] = $this->xmlToArray($value); } - - return $array; + return $array; } } \ No newline at end of file