_enable_in_wizard = false; $this->_enable_in_hover = true; } /* * getItem * * As the linked in connector does not have a true API call, we simply * override this abstract method */ public function getItem($args=array(), $module=null){} /* * getList * * As the linked in connector does not have a true API call, we simply * override this abstract method */ public function getList($args = array(), $module = null) { $params = array('count' => 10, 'start' => 0); if (!empty($args['maxResults'])) $params['count'] = $args['maxResults']; if (!empty($args['startIndex'])) $params['start'] = $args['startIndex']; $results = FALSE; try { $queryFields = "(id,first-name,last-name,industry,headline,summary,location:(name,country:(code)),positions:(title,summary,company:(name)))"; $url = "http://api.linkedin.com/v1/people/~/connections:$queryFields"; $response = $this->_eapm->makeRequest("GET", $url, $params); $results = $this->formatListResponse($response); } catch (Exception $e) { $GLOBALS['log']->fatal("Unable to retrieve item list for linkedin connector."); } return $results; } private function formatListResponse($resp) { $records = array(); $xmlResp = simplexml_load_string($resp); if ($xmlResp === FALSE) throw new Exception('Unable to parse list response'); foreach ($xmlResp->person as $person) { $tmp = array(); $this->convertPersonListResponeToArray($person, $tmp); $records[] = $tmp; } return array('totalResults' => (int)$xmlResp->attributes()->total, 'startIndex' => (int)$xmlResp->attributes()->start, 'records' => $records); } private function convertPersonListResponeToArray(SimpleXMLElement $xmlResp, &$result, $suffix = '') { foreach ((array)$xmlResp as $k => $v) { $key = !empty($suffix) ? "{$suffix}-{$k}" : $k; if ($v instanceof SimpleXMLElement) { $this->convertPersonListResponeToArray($v, $result, $key); } else if (is_array($v)) //Skip over attributes { if ($k == 'position') { $latestPosition = $v[0]; $result['company_name'] = (string)$latestPosition->company->name; $result['title'] = (string)$latestPosition->title; $result['position-summary'] = (string)$latestPosition->summary; } } else { $result[$key] = $v; } } } } ?>