/**
  * callback.
  *
  * @return	void
  */
 public function callback()
 {
     if ($this->csrfProtection) {
         $this->_csrfProtection();
     }
     try {
         // $channelId = $this->input->getUint('channelId');
         $session = JFactory::getSession();
         $channelId = $session->get('channelId');
         // Invalidating
         $session->set('channelId', false);
         $code = $this->input->getString('code');
         $state = $this->input->getString('state');
         if (!empty($code)) {
             $channel = F0FTable::getAnInstance('Channel', 'AutoTweetTable');
             $result = $channel->load($channelId);
             if (!$result) {
                 throw new Exception('LinkedIn Channel failed to load!');
             }
             $lioauth2ChannelHelper = new LiOAuth2ChannelHelper($channel);
             $lioauth2ChannelHelper->authenticate($code, $state);
             // Redirect
             $url = 'index.php?option=com_autotweet&view=channels&task=edit&id=' . $channelId;
             $this->setRedirect($url);
             $this->redirect();
         }
     } catch (Exception $e) {
         $logger = AutotweetLogger::getInstance();
         $logger->log(JLog::ERROR, $e->getMessage());
         throw $e;
     }
 }
Beispiel #2
0
 /**
  * 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();
 }
Beispiel #3
0
$required = array('class' => 'required', 'required' => 'required');
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)) {
/**
 * @package     Extly.Components
 * @subpackage  com_autotweet - A powerful social content platform to manage multiple social networks.
 *
 * @author      Prieco S.A. <*****@*****.**>
 * @copyright   Copyright (C) 2007 - 2015 Prieco, S.A. All rights reserved.
 * @license     http://www.gnu.org/licenses/gpl-3.0.html GNU/GPL
 * @link        http://www.extly.com http://support.extly.com
 */
// No direct access
defined('_JEXEC') or die('Restricted access');
$channeltypeId = $this->input->get('channeltype_id', AutotweetModelChanneltypes::TYPE_LIOAUTH2_CHANNEL, 'cmd');
$accessTokenEncoded = htmlentities($accessToken);
$expires_date = $this->item->xtform->get('expires_date');
$expires_date = EParameter::convertUTCLocal($expires_date);
$lioauth2ChannelHelper = new LiOAuth2ChannelHelper($this->item);
$authUrl = $lioauth2ChannelHelper->getAuthorizationUrl();
if (!empty($accessTokenEncoded) && $channeltypeId == AutotweetModelChanneltypes::TYPE_LIOAUTH2COMPANY_CHANNEL) {
    ?>

<div class="control-group">
	<label class="required control-label" for="xtformlioauth2company_id" id="lioauth2company_id-lbl"><?php 
    echo JText::_('COM_AUTOTWEET_CHANNEL_LINKEDIN_COMPANY_ID');
    ?>
 <span class="star">&nbsp;*</span></label>
	<div class="controls">
		<a class="btn btn-info" id="lioauth2companyloadbutton"><?php 
    echo JText::_('COM_AUTOTWEET_VIEW_CHANNEL_LOADBUTTON_TITLE');
    ?>
</a>
		<?php