Beispiel #1
0
 /**
  * getLiCompanies
  *
  * @return	void
  */
 public function getLiCompanies()
 {
     @ob_end_clean();
     header('Content-type: text/plain');
     $this->_loadLiParams();
     JLoader::register('LiAppHelper', JPATH_AUTOTWEET_HELPERS . '/channels/liapp.php');
     $status = false;
     $error_message = 'Unknown';
     $icon = null;
     try {
         $liAppHelper = new LiAppHelper($this->_api_key, $this->_secret_key, $this->_oauth_user_token, $this->_oauth_user_secret);
         if ($liAppHelper->login()) {
             $channels = $liAppHelper->getMyCompanies();
             $icon = F0FModel::getTmpInstance('Channeltypes', 'AutoTweetModel')->getIcon(AutotweetModelChanneltypes::TYPE_LINK_CHANNEL);
             $status = true;
             $error_message = 'Ok';
         } else {
             $error_message = 'LiCompanies Login Failed!';
         }
     } catch (Exception $e) {
         $error_message = $e->getMessage();
     }
     if (count($channels) == 2 && $channels[0] == false) {
         $message = json_encode(array('status' => false, 'error_message' => $channels[1]));
     } else {
         $message = json_encode(array('status' => $status, 'error_message' => $error_message, 'channels' => $channels, 'icon' => $icon));
     }
     echo EJSON_START . $message . EJSON_END;
     flush();
     JFactory::getApplication()->close();
 }
Beispiel #2
0
 /**
  * licompanies.
  *
  * @param   string  $selected           The key that is selected
  * @param   string  $name               The name for the field
  * @param   array   $attribs            Additional HTML attributes for the <select> tag*
  * @param   string  $api_key            Params
  * @param   string  $secret_key         Params
  * @param   string  $oauth_user_token   Params
  * @param   string  $oauth_user_secret  Params
  *
  * @return  string  HTML
  */
 public static function licompanies($selected = null, $name = 'xtform[company_id]', $attribs = array(), $api_key = null, $secret_key = null, $oauth_user_token = null, $oauth_user_secret = null)
 {
     $options = array();
     $attribs = array();
     if (!empty($oauth_user_secret)) {
         require_once dirname(__FILE__) . '/../helpers/channels/liapp.php';
         try {
             $liAppHelper = new LiAppHelper($api_key, $secret_key, $oauth_user_token, $oauth_user_secret);
             if ($liAppHelper->login()) {
                 $channels = $liAppHelper->getMyCompanies();
                 if (count($channels) > 0 && $channels[0]) {
                     $icon = F0FModel::getTmpInstance('Channeltypes', 'AutoTweetModel')->getIcon(AutotweetModelChanneltypes::TYPE_LINK_CHANNEL);
                     foreach ($channels as $channel) {
                         $nm = $channel->name;
                         if (empty($nm) || $nm == 'null') {
                             $nm = $channel->id;
                         }
                         $attr = 'social_url="' . $channel->url . '" social_icon="' . $icon . '"';
                         $attrs = array('attr' => $attr, 'option.attr' => 'social_url', 'option.key' => 'value', 'option.text' => 'text', 'disable' => false);
                         $opt = JHTML::_('select.option', $channel->id, $nm, $attrs);
                         $options[] = $opt;
                     }
                 }
                 $attribs['id'] = $name;
                 $attribs['list.attr'] = null;
                 $attribs['list.translate'] = false;
                 $attribs['option.key'] = 'value';
                 $attribs['option.text'] = 'text';
                 $attribs['option.attr'] = 'social_url';
                 $attribs['list.select'] = $selected;
                 return EHtmlSelect::genericlist($options, $name, $attribs);
             } else {
                 $error_message = 'LinkedIn Login Failed (Companies)!';
                 $options[] = JHTML::_('select.option', '', $error_message);
             }
         } catch (Exception $e) {
             $error_message = $e->getMessage();
             $options[] = JHTML::_('select.option', '', $error_message);
         }
     } else {
         $options[] = JHTML::_('select.option', null, '-' . JText::_('JSELECT') . '-');
     }
     return EHtmlSelect::customGenericList($options, $name, $attribs, $selected, $name, array('option.attr' => 'access_token'));
 }