Skip to content

Commit

Permalink
Fixed LinkedIn xml parser.
Browse files Browse the repository at this point in the history
  • Loading branch information
Nodge committed Jun 8, 2012
1 parent 9de5195 commit 0e8066c
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions services/LinkedinOAuthService.php
Expand Up @@ -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;
}
}

0 comments on commit 0e8066c

Please sign in to comment.