/** * @param $callbackUrl * @param null $accessToken * @return SimpleXMLElement * @throws Exception */ public function authorize($callbackUrl, $accessToken = null) { self::$object = new SJB_LinkedIn($callbackUrl); if (empty($accessToken)) { // check for response from LinkedIn if (!$this->isTokenRequested()) { self::$object->_getRequestToken(); } else { if (SJB_Request::getVar(SJB_LinkedIn::OAUTH_PROBLEM)) { throw new Exception('oAuth Problem: ' . SJB_Request::getVar(SJB_LinkedIn::OAUTH_PROBLEM)); } } } self::$object->_getAccessToken($accessToken); $response = self::$object->getProfileInfo(array('id', 'email-address')); return new SimpleXMLElement($response); }
private function getProfileInformation() { if (!$this->takeDataFromServer && ($oCurUser = SJB_UserManager::getCurrentUser())) { $curUserSID = $oCurUser->getSID(); $profileSocialID = self::getProfileSocialID($curUserSID); if ($profileSocialID) { $aProfExpl = explode($this->getNetwork() . '_', $profileSocialID); $linkedinID = $aProfExpl[1]; $profileSocialInfo = $this->getProfileSocialSavedInfoBySocialID($linkedinID); if ($profileSocialInfo) { self::$oProfile = $profileSocialInfo['profile_info']; self::$oSocialPlugin = $this; if (SJB_HelperFunctions::debugModeIsTurnedOn()) { SJB_HelperFunctions::debugInfoPush(self::$oProfile, 'SOCIAL_PLUGIN'); } return true; } } } if (self::$object) { try { $response = self::$object->getProfileInfo($this->requestedProfileFields); if ($response) { self::$oProfile = new SimpleXMLElement($response); self::$oSocialPlugin = $this; if (SJB_HelperFunctions::debugModeIsTurnedOn()) { SJB_HelperFunctions::debugInfoPush(self::$oProfile, 'SOCIAL_PLUGIN'); } return true; } } catch (Exception $ex) { // revocation successful, clear session unset($_SESSION['oauth'][self::NETWORK_ID]); $this->cleanSessionData(self::NETWORK_ID); if (SJB_HelperFunctions::debugModeIsTurnedOn()) { $debug = "Error retrieving profile information:\n\nRESPONSE:\n\n<pre>" . print_r($ex->getMessage()) . "</pre>"; SJB_HelperFunctions::debugInfoPush($debug, 'SOCIAL_PLUGINS'); } } } return null; }