/** * getLiOAuth2Validation. * * @return void */ public function getLiOAuth2Validation() { @ob_end_clean(); header('Content-type: text/plain'); // No JInputJSON in J2.5 $raw = file_get_contents('php://input'); $data = json_decode($raw, true); $safeHtmlFilter = JFilterInput::getInstance(); $token = $data['token']; $token = $safeHtmlFilter->clean($token, 'ALNUM'); $this->input->set($token, 1); // CSRF prevention if ($this->csrfProtection) { $this->_csrfProtection(); } $channel_id = $data['channel_id']; $channel_id = $safeHtmlFilter->clean($channel_id, 'ALNUM'); $channel = F0FTable::getAnInstance('Channel', 'AutoTweetTable'); $result = $channel->load($channel_id); $channel->xtform = EForm::paramsToRegistry($channel); $status = false; $error_message = 'Unknown'; $user = null; $userId = null; $url = null; $icon = null; try { $liOAuth2ChannelHelper = new LiOAuth2ChannelHelper($channel); $isAuth = $liOAuth2ChannelHelper->isAuth(); if ($isAuth && is_array($isAuth) && array_key_exists('user', $isAuth)) { $user = $isAuth['user']; $status = true; $error_message = 'Ok'; $url = $liOAuth2ChannelHelper->getSocialUrl($user); $userId = $user->id; $icon = F0FModel::getTmpInstance('Channeltypes', 'AutoTweetModel')->getIcon(AutoTweetModelChanneltypes::TYPE_LIOAUTH2_CHANNEL); } else { $error_message = 'LinkedIn OAuth2 Login Failed!'; } } catch (Exception $e) { $error_message = $e->getMessage(); } $message = json_encode(array('status' => $status, 'error_message' => $error_message, 'user' => $userId, 'icon' => $icon, 'url' => $url)); echo EJSON_START . $message . EJSON_END; flush(); JFactory::getApplication()->close(); }
echo EHtml::textControl($this->item->xtform->get('consumer_key'), 'xtform[consumer_key]', 'COM_AUTOTWEET_CHANNEL_LIOAUTH2_CONSUMER_KEY', 'COM_AUTOTWEET_CHANNEL_LIOAUTH2_CONSUMER_KEY_DESC', 'consumer_key', 60, $required); echo EHtml::textControl($this->item->xtform->get('consumer_secret'), 'xtform[consumer_secret]', 'COM_AUTOTWEET_CHANNEL_LIOAUTH2_CONSUMER_SECRET', 'COM_AUTOTWEET_CHANNEL_LIOAUTH2_CONSUMER_SECRET_DESC', 'consumer_secret', 60, $required); $accessToken = null; $accessTokenSecret = null; $user = null; $userId = null; $authUrl = '#'; $authUrlButtonStyle = 'disabled'; $validationGroupStyle = 'hide'; // New channel, not even saved if ($this->item->id == 0) { $message = JText::_('COM_AUTOTWEET_CHANNEL_LIOAUTH2_NEWCHANNEL_NOAUTHORIZATION'); include_once 'auth_button.php'; } else { $lioauth2ChannelHelper = new LiOAuth2ChannelHelper($this->item); $isAuth = $lioauth2ChannelHelper->isAuth(); // New channel, but saved if ($isAuth && is_array($isAuth) && array_key_exists('user', $isAuth)) { // We have an access Token! $user = $isAuth['user']; $userId = $user->id; $this->item->xtform->set('social_url', $lioauth2ChannelHelper->getSocialUrl($user)); $validationGroupStyle = null; $accessToken = $this->item->xtform->get('access_token'); $accessTokenSecret = $this->item->xtform->get('access_secret'); include_once 'validation_button.php'; } else { $message = JText::_('COM_AUTOTWEET_CHANNEL_LIOAUTH2_NEWCHANNEL_AUTHORIZATION'); $authUrl = $lioauth2ChannelHelper->getAuthorizationUrl(); if (!empty($authUrl)) { $authUrlButtonStyle = null;