Esempio n. 1
0
 /**
  * getFbAlbums.
  *
  * @return	void
  */
 public function getFbAlbums()
 {
     @ob_end_clean();
     header('Content-type: text/plain');
     $this->_loadFbParams();
     JLoader::register('FbAppHelper', JPATH_AUTOTWEET_HELPERS . '/channels/fbapp.php');
     $status = false;
     $error_message = 'Unknown';
     try {
         $fbAppHelper = new FbAppHelper($this->_app_id, $this->_secret, $this->_access_token);
         if ($fbAppHelper->login()) {
             // $this->_channel_access_token ?
             $channels = $fbAppHelper->getAlbums($this->_channel_id);
             $status = true;
             $error_message = 'Ok';
         } else {
             $error_message = 'Facebook Login Failed!';
         }
     } catch (Exception $e) {
         $error_message = $e->getMessage();
     }
     $message = json_encode(array('status' => $status, 'error_message' => $error_message, 'albums' => $channels));
     echo EJSON_START . $message . EJSON_END;
     flush();
     JFactory::getApplication()->close();
 }
Esempio n. 2
0
 /**
  * fbalbums.
  *
  * @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  $app_id        Params
  * @param   string  $secret        Params
  * @param   string  $access_token  Params
  * @param   string  $channelid     Params
  *
  * @return  string  HTML
  */
 public static function fbalbums($selected = null, $name = 'xtform[fbalbum_id]', $attribs = array(), $app_id = null, $secret = null, $access_token = null, $channelid = null)
 {
     $options = array();
     $attribs = array();
     if ($access_token) {
         require_once dirname(__FILE__) . '/../helpers/channels/fbapp.php';
         try {
             $fbAppHelper = new FbAppHelper($app_id, $secret, $access_token);
             if ($fbAppHelper->login()) {
                 $albums = $fbAppHelper->getAlbums($channelid);
                 foreach ($albums as $album) {
                     $nm = $album['name'];
                     if (empty($nm) || $nm == 'null') {
                         $nm = $album['id'];
                     }
                     $opt = JHTML::_('select.option', $album['id'], $nm);
                     $options[] = $opt;
                 }
                 $attribs['id'] = $name;
                 $attribs['list.attr'] = null;
                 $attribs['list.translate'] = false;
                 $attribs['option.key'] = 'value';
                 $attribs['option.text'] = 'text';
                 $attribs['list.select'] = $selected;
                 return EHtmlSelect::genericlist($options, $name, $attribs);
             } else {
                 $error_message = 'Facebook Login Failed!';
                 $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'));
 }