Beispiel #1
0
        public void TestMethod1()
        {
            var flickrApi = new FlickrApi("");
            var response  = flickrApi.PeopleGetPublicPhotos("27725019@N00");

            Console.WriteLine(response);
        }
Beispiel #2
0
        public async Task <IEnumerable <OriginalImage> > GetOriginalData(string id)
        {
            try
            {
                var albumImages = await FlickrApi.GetImageUrls(id, Configuration.Instance["flickr-token"]);

                var match = albumImages.sizes.size.FirstOrDefault(n => n.label == "Original");
                if (match == null)
                {
                    match = albumImages.sizes.size.FirstOrDefault(n => n.label == "Large");
                    if (match == null)
                    {
                        return(null);
                    }
                }
                return(new OriginalImage[]
                {
                    new OriginalImage {
                        Url = match.source
                    }
                });
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                throw;
            }
        }
Beispiel #3
0
        public MainViewModel()
        {
            _flickrApi = new FlickrApi();

            SearchCommand   = new Command <string>(Search);
            LoadMoreCommand = new Command(LoadMore);
            Photos          = new ObservableCollection <Photo>();
        }
Beispiel #4
0
        public Flickr()
        {
            InitializeComponent();

            flickrApi = new FlickrApi();

            //put all the imageQualityRadioButtons into a list
            imageQualityRadioButtons = new List <RadioButton>();
            imageQualityRadioButtons.AddRange(imageQualityTableLayoutPanel.Controls.OfType <RadioButton>());
        }
        public OAuthController()
        {
            _oAuthUrlService = new OAuthUrlService(new SimplickrConfigurationProvider());
            IHttpClient httpClient = new HttpClient();

            _oAuthService = new OAuthService(_oAuthUrlService, httpClient, new QueryStringSerializer());

            ISimplickrFormatter             simplickrFormatter             = new SimplickrJsonFormatter();
            ISimplickrConfigurationProvider simplickrConfigurationProvider = new SimplickrConfigurationProvider();
            var flickrRequestBuilder = new FlickrRequestUrlProvider(simplickrFormatter, simplickrConfigurationProvider);

            _flickrApi = new FlickrApi(new FlickrApiInvoker(flickrRequestBuilder, httpClient, simplickrFormatter));
        }
Beispiel #6
0
        public OAuthServiceTests()
        {
            _oAuthUrlService = new OAuthUrlService(new SimplickrConfigurationProvider());
            _oAuthService    = new OAuthService(_oAuthUrlService, new HttpClient(), new QueryStringSerializer());

            _callbackUrl = "http://portfotolio.local/-oauth/authorize";

            ISimplickrFormatter             simplickrFormatter             = new SimplickrJsonFormatter();
            ISimplickrConfigurationProvider simplickrConfigurationProvider = new SimplickrConfigurationProvider();
            var         flickrRequestBuilder = new FlickrRequestUrlProvider(simplickrFormatter, simplickrConfigurationProvider);
            IHttpClient httpClient           = new HttpClient();

            _flickrApi = new FlickrApi(new FlickrApiInvoker(flickrRequestBuilder, httpClient, simplickrFormatter));
        }
Beispiel #7
0
        public async Task <IEnumerable <StereoImage> > ScrapeAlbum(string userId, string albumId, string userName)
        {
            var photos = await FlickrApi.GetAlbum(userId, albumId, Configuration.Instance["flickr-token"]);

            var result = new List <StereoImage>();

            foreach (var photo in photos.photoset.photo)
            {
                Console.WriteLine($"Processing photo {photo.id}");
                var image = await GetOriginalData(photo.id);

                result.AddRange(image.Select(n => new StereoImage(
                                                 url: new Uri(string.Format(PhotoPageUrlFormat, userName, photo.id)),
                                                 imageUrl: new Uri(photo.url_o),
                                                 title: photo.title,
                                                 link: n.FileName,
                                                 uploadDate: default(DateTime)
                                                 )));
            }
            return(result);
        }
Beispiel #8
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);
                            }
                        }
                    }
                }
            }
        }