Exemple #1
0
 function get_facebook_feed_response($FB_Shortcode, $fb_cache_name, $access_token, $language)
 {
     if (false !== ($transient_exists = $this->fts_check_feed_cache_exists($fb_cache_name)) and !isset($_GET['load_more_ajaxing'])) {
         $response = $this->fts_get_feed_cache($fb_cache_name);
     } else {
         //Page
         if ($FB_Shortcode['type'] == 'page' && $FB_Shortcode['posts_displayed'] == 'page_only') {
             $mulit_data = array('page_data' => 'https://graph.facebook.com/' . $FB_Shortcode['id'] . '?fields=id,name,description&access_token=' . $access_token . $language . '');
             $mulit_data['feed_data'] = isset($_REQUEST['next_url']) ? $_REQUEST['next_url'] : 'https://graph.facebook.com/' . $FB_Shortcode['id'] . '/posts?fields=id,caption,created_time,description,from,icon,link,message,name,object_id,picture,place,shares,source,status_type,story,to,type&limit=' . $FB_Shortcode['posts'] . '&access_token=' . $access_token . $language . '';
         } elseif ($FB_Shortcode['type'] == 'events') {
             date_default_timezone_set(get_option('fts-timezone'));
             $date = date('Y-m-d');
             $mulit_data = array('page_data' => 'https://graph.facebook.com/' . $FB_Shortcode['id'] . '?fields=id,name&access_token=' . $access_token . $language . '');
             //Check If Ajax next URL needs to be used
             $mulit_data['feed_data'] = isset($_REQUEST['next_url']) ? $_REQUEST['next_url'] : 'https://graph.facebook.com/' . $FB_Shortcode['id'] . '/events?since=' . $date . '&access_token=' . $access_token . $language . '';
         } elseif ($FB_Shortcode['type'] == 'albums') {
             $mulit_data = array('page_data' => 'https://graph.facebook.com/' . $FB_Shortcode['id'] . '?fields=id,name,description,link&access_token=' . $access_token . $language . '');
             //Check If Ajax next URL needs to be used
             $mulit_data['feed_data'] = isset($_REQUEST['next_url']) ? $_REQUEST['next_url'] : 'https://graph.facebook.com/' . $FB_Shortcode['id'] . '/albums?fields=id,created_time,name,from,link,cover_photo,count,updated_time,type&limit=' . $FB_Shortcode['posts'] . '&access_token=' . $access_token . $language . '';
         } elseif ($FB_Shortcode['type'] == 'album_photos') {
             $mulit_data = array('page_data' => 'https://graph.facebook.com/' . $FB_Shortcode['id'] . '?fields=id,name,description&access_token=' . $access_token . $language . '');
             //Check If Ajax next URL needs to be used
             //The reason I did not create a whole new else if for the video album is because I did not want to duplicate all the code required to make the video because the videos gallery comes from the photo albums on facebook.
             if (isset($FB_Shortcode['video_album']) && $FB_Shortcode['video_album'] == 'yes') {
                 $mulit_data['feed_data'] = isset($_REQUEST['next_url']) ? $_REQUEST['next_url'] : 'https://graph.facebook.com/' . $FB_Shortcode['album_id'] . '/videos?fields=id,created_time,description,from,icon,link,message,name,object_id,picture,place,shares,source,to,type,format,embed_html&limit=' . $FB_Shortcode['posts'] . '&access_token=' . $access_token . $language . '';
             } else {
                 $mulit_data['feed_data'] = isset($_REQUEST['next_url']) ? $_REQUEST['next_url'] : 'https://graph.facebook.com/' . $FB_Shortcode['album_id'] . '/photos?fields=id,caption,created_time,description,from,icon,link,message,name,object_id,picture,place,shares,source,status_type,story,to,type&limit=' . $FB_Shortcode['posts'] . '&access_token=' . $access_token . $language . '';
             }
         } elseif ($FB_Shortcode['type'] == 'hashtag') {
             $mulit_data = array('page_data' => 'https://graph.facebook.com/search?q=%23' . $FB_Shortcode['id'] . '&access_token=' . $access_token . $language . '');
             //Check If Ajax next URL needs to be used
             $mulit_data['feed_data'] = isset($_REQUEST['next_url']) ? $_REQUEST['next_url'] : 'https://graph.facebook.com/search?q=%23' . $FB_Shortcode['id'] . '&limit=' . $FB_Shortcode['posts'] . '&access_token=' . $access_token . $language . '';
             //Check If Ajax next URL needs to be used
         } elseif ($FB_Shortcode['type'] == 'group') {
             $mulit_data = array('page_data' => 'https://graph.facebook.com/' . $FB_Shortcode['id'] . '?fields=id,name,description&access_token=' . $access_token . $language . '');
             //Check If Ajax next URL needs to be used
             $mulit_data['feed_data'] = isset($_REQUEST['next_url']) ? $_REQUEST['next_url'] : 'https://graph.facebook.com/' . $FB_Shortcode['id'] . '/feed?fields=id,caption,created_time,description,from,icon,link,message,name,object_id,picture,place,shares,source,status_type,story,to,type&limit=' . $FB_Shortcode['posts'] . '&access_token=' . $access_token . $language . '';
         } elseif ($FB_Shortcode['type'] == 'reviews') {
             if (is_plugin_active('feed-them-social-facebook-reviews/feed-them-social-facebook-reviews.php')) {
                 $FTS_Facebook_Reviews = new FTS_Facebook_Reviews();
                 $mulit_data = $FTS_Facebook_Reviews->review_connection($FB_Shortcode, $access_token, $language);
             } else {
                 return 'Please Purchase and Activate the Feed Them Social Reviews plugin.';
                 exit;
             }
         } else {
             $mulit_data = array('page_data' => 'https://graph.facebook.com/' . $FB_Shortcode['id'] . '?fields=id,name,description&access_token=' . $access_token . $language . '');
             //Check If Ajax next URL needs to be used
             $mulit_data['feed_data'] = isset($_REQUEST['next_url']) ? $_REQUEST['next_url'] : 'https://graph.facebook.com/' . $FB_Shortcode['id'] . '/feed?fields=id,caption,created_time,description,from,icon,link,message,name,object_id,picture,place,shares,source,status_type,story,to,type&limit=' . $FB_Shortcode['posts'] . '&access_token=' . $access_token . $language . '';
         }
         $response = $this->fts_get_feed_json($mulit_data);
         //Make sure it's not ajaxing
         if (!isset($_GET['load_more_ajaxing']) && !empty($response['feed_data'])) {
             //Create Cache
             $this->fts_create_feed_cache($fb_cache_name, $response);
         }
     }
     // end main else
     //RETURN THE RESPONSE!!!
     return $response;
 }