Пример #1
0
        public PartialViewResult FacebookpagePost(string access_token, string pageID)
        {
            FacebookObj            Post     = new FacebookApi(access_token, pageID, null).QueryPost();
            List <FacebookAccount> PostList = Post.data;

            return(PartialView("_FacebookPagePosts", PostList));
        }
Пример #2
0
        public ActionResult FacebookReply()
        {
            string app_id     = "379050216797422";
            string app_secret = "e0fb119bdbb7dd6d5096b525d9da115d";

            if (Request["code"] == null)
            {
                var redirecturl = string.Format("https://graph.facebook.com/oauth/authorize?client_id={0}&redirect_uri={1}", app_id, Request.Url.AbsoluteUri);
                Response.Redirect(redirecturl);
            }
            else
            {
                AccessToken    at      = new AccessToken();
                string         url     = string.Format("https://graph.facebook.com/v8.0/oauth/access_token?client_id={0}&redirect_uri={1}&client_secret={2}&code={3}", app_id, Request.Url.AbsoluteUri, app_secret, Request["code"].ToString());
                HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest;
                using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
                {
                    StreamReader reader = new StreamReader(response.GetResponseStream());
                    string       result = reader.ReadToEnd();
                    at = JsonConvert.DeserializeObject <AccessToken>(result);
                    ViewBag.access_token = at.access_token;
                }
                FacebookObj PageIds = new FacebookApi(at.access_token, null, null).QueryPages();
                ViewBag.PageIds = PageIds.data;
            }
            return(View());
        }
Пример #3
0
 public ActionResult FacebookReply(string message, string access_token)
 {
     if (message == null)
     {
         return(RedirectToAction("Contact", "Home"));
     }
     else
     {
         FacebookObj pageID = new FacebookApi(access_token, null, null).QueryPages();
         ViewBag.PageIds = pageID.data;
         foreach (var pageId in pageID.data)
         {
             FacebookObj postID = new FacebookApi(access_token, pageId.id, null).QueryPost();
             foreach (var postId in postID.data)
             {
                 FacebookAccount pageToken = new FacebookApi(access_token, pageId.id, postId.id).QueryPageToken();
                 FacebookObj     commentID = new FacebookApi(access_token, pageId.id, postId.id).QueryComments();
                 using (ApplicationDbContext db = new ApplicationDbContext())
                     foreach (var comment in commentID.data)
                     {
                         var replycomments = db.mMarketings.Where(a => a.CommentID == comment.id).ToList();
                         if (replycomments.Count == 0)
                         {
                             var replyComment = new FacebookApi(pageToken.access_token, pageId.id, postId.id).ReplyComment(comment.id, message);
                             db.mMarketings.Add(new MarketingViewModel {
                                 CommentID = comment.id
                             });
                             db.SaveChanges();
                         }
                     }
             }
         }
     }
     return(View());
 }
Пример #4
0
        public async Task <HttpResponseMessage> Post(dynamic body)
        {
            // Checks this is an event from a page subscription
            if (body.@object == "page")
            {
                // Iterates over each entry - there may be multiple if batched
                foreach (var entry in body.entry)
                {
                    // Gets the message. entry.messaging is an array, but
                    // will only ever contain one message, so we get index 0
                    dynamic messagingEntry = entry.messaging[0];
                    string  senderId       = messagingEntry.sender.id;
                    string  messageText    = messagingEntry.message.text;

                    FacebookApi fbApi = new FacebookApi();
                    await fbApi.SendMessage(senderId, $"Message received: {messageText}");
                }

                // Returns a '200 OK' response to all requests
                return(Request.CreateResponse(HttpStatusCode.OK, "EVENT_RECEIVED"));
            }
            else
            {
                // Returns a '404 Not Found' if event is not from a page subscription
                return(Request.CreateResponse(HttpStatusCode.NotFound));
            }
        }
Пример #5
0
        void FacebookLogin_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
        {
            ViewModelLocator.Register();
            bool offline = false;
            bool.TryParse(ConfigurationManager.AppSettings.Get("OfflineMode"), out offline);

            if (!offline)
            {
                if ((bool)e.NewValue)
                {
                    progressBarLogin.Visibility = System.Windows.Visibility.Visible;
                    fbapi = new FacebookApi(ConfigurationManager.AppSettings.Get("FacebookAppId"), ConfigurationManager.AppSettings.Get("FacebookAppPermissions"));
                    var loginUrl = fbapi.GetFacebookLoginUrl();
                    fbLoginBrowser.Navigate(loginUrl);
                }
            }
            else
            {
                _myEventsClient.AuthenticationService.GetFakeAuthorizationAsync((result) =>
                {
                    Credentials.UserCredentials.Current.UserId = result.RegisteredUserId;
                    Credentials.UserCredentials.Current.FacebookToken = "";
                    Credentials.UserCredentials.Current.FacebookId = result.FacebookUserId;
                    Credentials.UserCredentials.Current.MyEventsToken = result.Token;
                    Credentials.UserCredentials.Current.FullName = result.UserName;

                    _myEventsClient.SetAccessToken(Credentials.UserCredentials.Current.MyEventsToken);
                    Dispatcher.Invoke(() =>
                    {
                        progressBarLogin.Visibility = System.Windows.Visibility.Collapsed;
                        (this.DataContext as MainPageViewModel).ShowFacebookLogin = false;
                    });
                });
            }
        }
Пример #6
0
        public async Task <IActionResult> GetTenders()
        {
            var friends = await FacebookApi.GetUserFriends(null);

            var tenders = await DbContext.Profiles.Where(p => p.IsTender && friends.Contains(p.FacebookId)).ToArrayAsync();

            return(Ok(tenders.Select(p => p.ToProfileDto())));
        }
Пример #7
0
        public async Task LoginAsync(string provider)
        {
            var account = new SimpleAuth.Account();

            switch (provider)
            {
            case Constants.Providers.Google:
                var clientId          = Device.RuntimePlatform == Device.iOS ? Constants.ApiInfo.GoogleInfo.GoogleiOSClientId : Constants.ApiInfo.GoogleInfo.GoogleWebClientId;
                var clientSecret      = Device.RuntimePlatform == Device.iOS ? null : Constants.ApiInfo.GoogleInfo.GoogleClientSecret;
                var googAuthenticator = new GoogleApi(Constants.Providers.Google, clientId, clientSecret)
                {
                    Scopes = Constants.ApiInfo.GoogleInfo.GoogleScopes
                };
                account = await googAuthenticator.Authenticate();

                break;

            case Constants.Providers.Facebook:
                var facebookAuthenticator = new FacebookApi(Constants.Providers.Facebook, Constants.ApiInfo.FacebookInfo.FacebookAppId, Constants.ApiInfo.FacebookInfo.FacebookSecret);
                account = await facebookAuthenticator.Authenticate();

                break;

            case Constants.Providers.Microsoft:
                var microsoftAuthenticator = new MicrosoftLiveConnectApi(Constants.Providers.Microsoft, Constants.ApiInfo.MicrosoftInfo.MicrosoftAppId, Constants.ApiInfo.MicrosoftInfo.MicrosoftSecret)
                {
                    Scopes = Constants.ApiInfo.MicrosoftInfo.MicrosoftScopes
                };
                account = await microsoftAuthenticator.Authenticate();

                break;

            case Constants.Providers.Twitter:
                var twitterAuthenticator = new TwitterApi(Constants.Providers.Twitter, Constants.ApiInfo.TwitterInfo.TwitterAppId, Constants.ApiInfo.TwitterInfo.TwitterSecret)
                {
                    RedirectUrl = new Uri("https://mobile.twitter.com/home")
                };
                account = await twitterAuthenticator.Authenticate();

                break;

            case Constants.Providers.Local:
                break;

            default:
                break;
            }

            var oauthAccount = account as SimpleAuth.OAuthAccount;

            if (!string.IsNullOrEmpty(oauthAccount.Token))
            {
                await StoreToken(oauthAccount.Token);

                _navigation.NavigateToRoot <MainPageViewModel>(true, null);
            }
            return;
        }
Пример #8
0
 private void AuthorizationUriWorker_DoWork(object sender, DoWorkEventArgs e)
 {
     e.Result = FacebookApi.GetAuthorizationUri(
         OAuth2ResponseType.CodeAndToken,
         new FacebookPermission[] {
         FacebookPermission.UserGamesActivity
     }
         );
 }
Пример #9
0
        public async Task <IActionResult> GetFriends()
        {
            string facebookId = null;
            var    friends    = await FacebookApi.GetUserFriends(null);

            var profiles = await DbContext.Profiles.Where(p => friends.Contains(p.FacebookId)).ToArrayAsync();

            return(Ok(profiles.Select(p => p.ToProfileDto())));
        }
Пример #10
0
        public JsonResult FbGraphRequest(double lat, double lng, string texto)
        {
            FacebookApi fbApi = new FacebookApi();

            var listaNodos = fbApi.FindFacebookPlaces(lat, lng, texto);

            listaNodos = ValidarNodosEnRadio(lat, lng, 1.5, listaNodos);

            return(Json(new { listaNodos }, JsonRequestBehavior.AllowGet));
        }
Пример #11
0
 public FacebookHttpClient(FacebookApi facebookApi, IConfiguration configuration)
 {
     _configuration = configuration;
     _httpClient    = new HttpClient
     {
         BaseAddress = new Uri(_configuration.GetValue <string>("BaseUrlForConnectionFacebook"))
     };
     _httpClient.DefaultRequestHeaders
     .Accept
     .Add(new MediaTypeWithQualityHeaderValue("application/json"));
 }
Пример #12
0
        static async Task Main(string[] args)
        {
            var facebookClient = new FacebookApi("shit");

            try
            {
                var meInfo = await facebookClient.GetAsync("me");
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Пример #13
0
        public static async Task <UserProfileInfo> GetUserProfileInfo(string userId, string userAccessToken)
        {
            using (var response = await HttpClientPool.GetHttpClient()
                                  .GetAsync(FacebookApi.GetBasicUserInfoUrl(userId, userAccessToken)))
            {
                if (response.IsSuccessStatusCode)
                {
                    var responseJson = await response.Content.ReadAsStringAsync();

                    var userProfileInfo = JsonConvert.DeserializeObject <UserProfileInfo>(responseJson);
                    return(userProfileInfo);
                }

                throw new Exception("Error fetching user profile info.");
            }
        }
Пример #14
0
        public static async Task <string> ExchangeTokenForLongLivedToken(string tokenToExchange)
        {
            using (var response = await HttpClientPool.GetHttpClient()
                                  .GetAsync(FacebookApi.GetExchangeTokenUrl(tokenToExchange)))
            {
                if (response.IsSuccessStatusCode)
                {
                    var responseJson = await response.Content.ReadAsStringAsync();

                    var exchangeTokenData = JsonConvert.DeserializeObject <ExchangeTokenData>(responseJson);
                    return(exchangeTokenData.access_token);
                }

                throw new Exception("Could not exchange token for a long lived one.");
            }
        }
Пример #15
0
        public static async Task <DebugTokenData> GetFacebookAccessTokenDebugInfo(string inputToken)
        {
            using (var response =
                       await HttpClientPool.GetHttpClient().GetAsync(FacebookApi.GetDebugTokenUrl(inputToken)))
            {
                if (response.IsSuccessStatusCode)
                {
                    var responseJson = await response.Content.ReadAsStringAsync();

                    var debugTokenData = JsonConvert.DeserializeObject <DebugTokenDataRoot>(responseJson).data;
                    return(debugTokenData);
                }

                throw new Exception("Could not verify login with facebook. Please try again in some time.");
            }
        }
Пример #16
0
        public async Task <IActionResult> GetFriend(Guid id)
        {
            var friend = await DbContext.Profiles.FindAsync(id);

            if (friend == null)
            {
                return(NotFound());
            }

            var friends = await FacebookApi.GetUserFriends(null);

            if (!friends.Contains(friend.FacebookId))
            {
                return(Forbid());
            }

            return(Ok(friend.ToProfileDto()));
        }
Пример #17
0
        public async Task <IActionResult> Create([Bind("id,ItemName,price,ItemDevision,Description,amount")] Item item, IFormFile file)
        {
            if (ModelState.IsValid)
            {
                var memoryStream = new MemoryStream();
                file.CopyTo(memoryStream);
                var fileBytes = memoryStream.ToArray();
                item.image = fileBytes;
                _context.Add(item);
                await _context.SaveChangesAsync();

                FacebookApi fc = new FacebookApi();
                fc.PublishMessage(item.ItemName + " is the newest product on our shopping site.\n"
                                  + "Description: " + item.Description + ".\n"
                                  + "Only: " + item.amount + "units remained! hurry up!\n"
                                  + "Price: " + item.price + "$");

                return(RedirectToAction(nameof(Index)));
            }
            return(View(item));
        }
Пример #18
0
        public async Task <IActionResult> GetTenders(int id)
        {
            if (await DbContext.Bars.FindAsync(id) == null)
            {
                return(NotFound());
            }

            // Start time is right now
            var start = DateTime.UtcNow;
            // If it's between 12am and 2am, add 2 hours to the date, otherwise 26 (1 day + 2 hours)
            var end     = start.Date + TimeSpan.FromHours(start.TimeOfDay.Hours < 2 ? 2 : 26);
            var friends = await FacebookApi.GetUserFriends(User.Claims.Single(c => c.Type == "token").Value);

            var shifts = await DbContext.Shifts.Where(s =>
                                                      s.Bar.Id == id &&
                                                      s.Start <end &&
                                                               s.End> start &&
                                                      friends.Contains(s.Profile.FacebookId))
                         .ToArrayAsync();

            return(Ok(shifts.Select(s => s.ToDto())));
        }
Пример #19
0
        public async Task <HttpStatusCodeResult> FacebookWebhook(Feed feed)
        {
            db = new ApplicationDbContext();
            try
            {
                string access_token = db._Tokens.FirstOrDefault().ACcess_TOken;
                foreach (var e in feed.entry)
                {
                    foreach (var c in e.changes)
                    {
                        string pageId    = e.id;
                        string postId    = c.value.post_id;
                        string commentID = c.value.comment_id;
                        var    commented = db.Comment_IDss.Where(a => a.Comment_IDs == commentID).ToList();
                        if (commented.Count == 0)
                        {
                            string          message   = "Ola";
                            FacebookAccount pageToken = new FacebookApi(access_token, pageId, null).QueryPageToken();
                            if (commentID != null && c.value.message != null && c.value.message != message)
                            {
                                var commentReply = new FacebookApi(pageToken.access_token, pageId, postId).ReplyComment(commentID, message);
                                await db.SaveChangesAsync();

                                var privateReply = new FacebookApi(pageToken.access_token, pageId, postId).PrivateReply(commentID);
                            }
                        }
                    }
                    return(new HttpStatusCodeResult(HttpStatusCode.OK));
                }
                return(new HttpStatusCodeResult(HttpStatusCode.OK));
            }
            catch (Exception)
            {
                throw;
            }
        }
Пример #20
0
        void FacebookLogin_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
        {
            ViewModelLocator.Register();
            bool offline = false;

            bool.TryParse(ConfigurationManager.AppSettings.Get("OfflineMode"), out offline);

            if (!offline)
            {
                if ((bool)e.NewValue)
                {
                    progressBarLogin.Visibility = System.Windows.Visibility.Visible;
                    fbapi = new FacebookApi(ConfigurationManager.AppSettings.Get("FacebookAppId"), ConfigurationManager.AppSettings.Get("FacebookAppPermissions"));
                    var loginUrl = fbapi.GetFacebookLoginUrl();
                    fbLoginBrowser.Navigate(loginUrl);
                }
            }
            else
            {
                _myEventsClient.AuthenticationService.GetFakeAuthorizationAsync((result) =>
                {
                    Credentials.UserCredentials.Current.UserId        = result.RegisteredUserId;
                    Credentials.UserCredentials.Current.FacebookToken = "";
                    Credentials.UserCredentials.Current.FacebookId    = result.FacebookUserId;
                    Credentials.UserCredentials.Current.MyEventsToken = result.Token;
                    Credentials.UserCredentials.Current.FullName      = result.UserName;

                    _myEventsClient.SetAccessToken(Credentials.UserCredentials.Current.MyEventsToken);
                    Dispatcher.Invoke(() =>
                    {
                        progressBarLogin.Visibility = System.Windows.Visibility.Collapsed;
                        (this.DataContext as MainPageViewModel).ShowFacebookLogin = false;
                    });
                });
            }
        }
Пример #21
0
 public ProfileController(WavelengthDbContext context, FacebookApi api) : base(context, api)
 {
 }
Пример #22
0
        static void Main(string[] args)
        {
            Console.Write("ApiKey: ");
            apiKey = Console.ReadLine();
            if (apiKey.Split(' ').Length > 0)
            {
                secret = apiKey.Split(' ')[1];
                apiKey = apiKey.Split(' ')[0];
            }
            else
            {
                Console.Write("Secret: ");
                secret = Console.ReadLine();
            }

            FacebookApi fbApi = new FacebookApi(apiKey, secret);
            fbApi = new FacebookApi("consoleEntry");

            System.Net.HttpStatusCode statusCode;

            // this call is weird because facebook double encodes the JSON
            var result = fbApi.Call("admin.getAppProperties", new Dictionary<string, FacebookSharp.Methods.JsonBase>()
            {
                { "properties", Methods.JsonBase.Create(new string[] { "application_name", "ip_list" }) },
            }, false, out statusCode);
            Console.WriteLine(result.ToJsonString());
            Console.WriteLine();

            try
            {
                var errorResult = fbApi.Call<StandardInfo[]>("users.getStandardInfo", new Dictionary<string, FacebookSharp.Methods.JsonBase>()
                {
                    { "uids", Methods.JsonBase.Create("44400541") },
                    { "fields", Methods.JsonBase.Create(new string[] { "last_name", "first_name" }) },
                }, false, out statusCode);
                DisplayStandardInfo(errorResult);
            }
            catch (Methods.Errors.InvalidCallException ex)
            {
                DisplayException(ex);
            }
            Console.WriteLine();

            var result2 = fbApi.Call("users.getStandardInfo", new Dictionary<string, FacebookSharp.Methods.JsonBase>()
            {
                { "uids", Methods.JsonBase.Create(44400541) },
                { "fields", Methods.JsonBase.Create(new string[] { "last_name", "first_name" }) },
            }, false, out statusCode);
            Console.WriteLine(result2.ToJsonString());
            Console.WriteLine();

            var result3 = fbApi.Call<StandardInfo[]>("users.getStandardInfo", new Dictionary<string, FacebookSharp.Methods.JsonBase>()
            {
                { "uids", Methods.JsonBase.Create(44400541) },
                { "fields", Methods.JsonBase.Create(new string[] { "last_name", "first_name" }) },
            }, false, out statusCode);
            DisplayStandardInfo(result3);
            Console.WriteLine();

            var result4 = fbApi.Call<StandardInfo[]>("users.getStandardInfo", new Dictionary<string, FacebookSharp.Methods.JsonBase>()
            {
                { "uids", Methods.JsonBase.Create(new Int64[] { 44400541 }) },
                { "fields", Methods.JsonBase.Create(new string[] { "last_name", "first_name" }) },
            }, false, out statusCode);
            DisplayStandardInfo(result4);

            Console.ReadLine();
        }
Пример #23
0
 public WavelengthController(WavelengthDbContext context, FacebookApi api)
 {
     FacebookApi = api;
     DbContext   = context;
 }
Пример #24
0
        public void Initialize(Rendering rendering)
        {
            //Get current item
            var dataSource = rendering.DataSource;

            if (dataSource.IsNullOrEmpty())
            {
                dataSource = Sitecore.Configuration.Settings.GetSetting("FeedsDataSource", "{AF7BCA0A-4C7F-4ACA-9956-E4801143775A}");
            }

            CurrentItem = Sitecore.Context.Database.GetItem(dataSource);

            if (CurrentItem != null)
            {
                // Get all social feeds items
                var socialFeeds = CurrentItem.InnerItem.GetChildren().ToList();
                FacebookApi  = new FacebookApi();
                TwitterApi   = new TwitterApi();
                InstagramApi = new InstagramApi();
                YouTubeApi   = new YouTubeApi();
                PinterestApi = new PinterestApi();
                FlickrApi    = new FlickrApi();

                if (socialFeeds.Any())
                {
                    // Get facebook feed item and bind facebook api class properties
                    var facebookFeedItem = socialFeeds.FirstOrDefault(i => i.IsOfType(FacebookFeed.TemplateId));
                    if (facebookFeedItem != null)
                    {
                        var facebookFeed = new FacebookFeed(facebookFeedItem);
                        if (facebookFeed != null)
                        {
                            if (facebookFeed.FacebookAccount.TargetItem != null)
                            {
                                var facebookAccount = new FacebookAccount(facebookFeed.FacebookAccount.TargetItem);

                                if (facebookAccount.SocialLink != null)
                                {
                                    if (!ShowSocialFeed)
                                    {
                                        ShowSocialFeed = true;
                                    }
                                    FacebookApi.ApiId = string.Join("|",
                                                                    new string[]
                                    {
                                        facebookAccount.ApiId.Value, facebookAccount.ApiKey.Value
                                    });
                                    FacebookApi.Icon = facebookAccount.SocialLink != null
                                        ? MediaManager.GetMediaUrl(
                                        new SocialMedia(facebookAccount.SocialLink.TargetItem).SocialIcon.MediaItem)
                                        : "";

                                    // new BaseFeed()

                                    FacebookApi.Priority = GetPriority(facebookFeed.BaseFeed);
                                }
                            }
                        }
                    }

                    // Get twitter feed item and bind twitter api class properties
                    var twitterFeedItem = socialFeeds.FirstOrDefault(i => i.IsOfType(TwitterFeed.TemplateId));
                    if (twitterFeedItem != null)
                    {
                        var twitterFeed = new TwitterFeed(twitterFeedItem);
                        if (twitterFeed != null)
                        {
                            if (twitterFeed.TwitterAccount.TargetItem != null)
                            {
                                var twitterAccount = new TwitterAccount(twitterFeed.TwitterAccount.TargetItem);

                                if (!ShowSocialFeed)
                                {
                                    ShowSocialFeed = true;
                                }
                                TwitterApi.HashTagsWithTokens = string.Join("|", new string[]
                                {
                                    string.Join(",",
                                                twitterFeed.Hashtags.GetItems().Select(i => new Hashtag(i).Value.Value)),
                                    twitterAccount.TwitterToken.Value,
                                    twitterAccount.TwitterTokenSecret.Value,
                                    twitterAccount.TwitterConsumerKey.Value,
                                    twitterAccount.TwitterConsumerSecret.Value
                                });

                                TwitterApi.Icon = twitterAccount.SocialLink != null
                                    ? MediaManager.GetMediaUrl(
                                    new SocialMedia(twitterAccount.SocialLink.TargetItem).SocialIcon.MediaItem)
                                    : "";

                                TwitterApi.Priority = GetPriority(twitterFeed.BaseFeed);
                            }
                        }
                    }

                    // Get instagram feed item and bind instagram api class properties
                    var instagramFeedItem = socialFeeds.FirstOrDefault(i => i.IsOfType(InstagramFeed.TemplateId));

                    if (instagramFeedItem != null)
                    {
                        var instagramFeed = new InstagramFeed(instagramFeedItem);
                        if (instagramFeed != null)
                        {
                            if (instagramFeed.InstagramAccount.TargetItem != null)
                            {
                                var instagramAccount = new InstagramAccount(instagramFeed.InstagramAccount.TargetItem);

                                if (!ShowSocialFeed)
                                {
                                    ShowSocialFeed = true;
                                }
                                InstagramApi.HashTags = string.Join(",",
                                                                    instagramFeed.Hashtags.GetItems().Select(i => new Hashtag(i).Value.Value));
                                InstagramApi.AccessToken = instagramAccount.AccessToken.Value;
                                InstagramApi.ClientId    = instagramAccount.InstagramClientId.Value;
                                InstagramApi.Icon        = instagramAccount.SocialLink != null
                                    ? MediaManager.GetMediaUrl(
                                    new SocialMedia(instagramAccount.SocialLink.TargetItem).SocialIcon.MediaItem)
                                    : "";


                                InstagramApi.Priority = GetPriority(instagramFeed.BaseFeed);
                            }
                        }
                    }


                    // Get youtube feed item and bind youtube api class properties
                    var youTubeFeedItem = socialFeeds.FirstOrDefault(i => i.IsOfType(YoutubeFeed.TemplateId));
                    if (youTubeFeedItem != null)
                    {
                        var youTubeFeed = new YoutubeFeed(youTubeFeedItem);
                        if (youTubeFeed.YouTubeAccount.TargetItem != null)
                        {
                            var youtubeAccount = new YoutubeAccount(youTubeFeed.YouTubeAccount.TargetItem);

                            if (!ShowSocialFeed)
                            {
                                ShowSocialFeed = true;
                            }
                            YouTubeApi.AccountId     = youtubeAccount.AccountId.Value;
                            YouTubeApi.AccountApiKey = youtubeAccount.AccountApiKey.Value;

                            YouTubeApi.Icon = youtubeAccount.SocialLink != null
                                ? MediaManager.GetMediaUrl(
                                new SocialMedia(youtubeAccount.SocialLink.TargetItem).SocialIcon.MediaItem)
                                : "";

                            YouTubeApi.Priority = GetPriority(youTubeFeed.BaseFeed);
                        }
                    }

                    // Get pinterest feed item and bind pinterest api class properties
                    var pinterestFeedItem = socialFeeds.FirstOrDefault(i => i.IsOfType(PinterestFeed.TemplateId));
                    if (pinterestFeedItem != null)
                    {
                        var pinterestFeed = new PinterestFeed(pinterestFeedItem);
                        if (pinterestFeed != null && pinterestFeed.PinterestAccount.TargetItem != null)
                        {
                            var pinterestAccount = new PinterestAccount(pinterestFeed.PinterestAccount.TargetItem);


                            if (!ShowSocialFeed)
                            {
                                ShowSocialFeed = true;
                            }
                            PinterestApi.AccountId = pinterestAccount.AccountId.Value;

                            PinterestApi.Icon = pinterestAccount.SocialLink != null
                                ? MediaManager.GetMediaUrl(
                                new SocialMedia(pinterestAccount.SocialLink.TargetItem).SocialIcon.MediaItem)
                                : "";

                            PinterestApi.Priority = GetPriority(pinterestFeed.BaseFeed);
                        }
                    }

                    // Get flickr feed item and bind flickr api class properties
                    var flickrFeedItem = socialFeeds.FirstOrDefault(i => i.IsOfType(FlickrFeed.TemplateId));
                    if (flickrFeedItem != null)
                    {
                        var flickrFeed = new FlickrFeed(flickrFeedItem);
                        if (flickrFeed != null)
                        {
                            if (flickrFeed.FlickrAccount.TargetItem != null)
                            {
                                var flickrAccount = new FlickrAccount(flickrFeed.FlickrAccount.TargetItem);

                                if (!ShowSocialFeed)
                                {
                                    ShowSocialFeed = true;
                                }
                                FlickrApi.AccountId = flickrAccount.AccountId.Value;
                                FlickrApi.Icon      = flickrAccount.SocialLink != null
                                    ? MediaManager.GetMediaUrl(
                                    new SocialMedia(flickrAccount.SocialLink.TargetItem).SocialIcon.MediaItem)
                                    : "";

                                FlickrApi.Priority = GetPriority(flickrFeed.BaseFeed);
                            }
                        }
                    }
                }
            }
        }