Exemplo n.º 1
3
        public IPhoto UploadPhoto(Stream stream, string filename, string title, string description, string tags)
        {
            using (MiniProfiler.Current.Step("FlickrPhotoRepository.UploadPhoto"))
            {
                Flickr fl = new Flickr();

                string authToken = (ConfigurationManager.AppSettings["FlickrAuth"] ?? "").ToString();
                if (string.IsNullOrEmpty(authToken))
                    throw new ApplicationException("Missing Flickr Authorization");

                fl.AuthToken = authToken;
                string photoID = fl.UploadPicture(stream, filename, title, description, tags, true, true, false,
                    ContentType.Photo, SafetyLevel.Safe, HiddenFromSearch.Visible);
                var photo = fl.PhotosGetInfo(photoID);
                var allSets = fl.PhotosetsGetList();
                var blogSet = allSets
                                .FirstOrDefault(s => s.Description == "Blog Uploads");
                if (blogSet != null)
                    fl.PhotosetsAddPhoto(blogSet.PhotosetId, photo.PhotoId);

                FlickrPhoto fphoto = new FlickrPhoto();
                fphoto.Description = photo.Description;
                fphoto.WebUrl = photo.MediumUrl;
                fphoto.Title = photo.Title;
                fphoto.Description = photo.Description;

                return fphoto;
            }
        }
        public string Upload(WitnessKingTidesApiInputModel model)
        {
            string flickrId = string.Empty;
            model.FileName = Guid.NewGuid().ToString() + ".jpg";

            var flickr = new Flickr(FlickrApiKey, FlickrApiSecret);
            flickr.OAuthAccessToken = FlickrOAuthKey;
            flickr.OAuthAccessTokenSecret = FlickrOAuthSecret;

            var path = Path.Combine(AppDataDirectory, model.FileName);
            using (var stream = File.OpenWrite(path))
            {
                stream.Write(model.Photo, 0, model.Photo.Length);
            }

            //TODO: We should probably fill the title here. Otherwise default flickr captions will be gibberish guids
            flickrId = flickr.UploadPicture(path, null, model.Description, null, true, false, false);

            //TODO: Should probably try/catch this section here. Failure to set location and/or delete the temp file should
            //not signal a failed upload.

            //TODO: Need to check if coordinates can be embedded in EXIF and extracted by Flickr. If so we can probably
            //skip this and embed the coordinates client-side.
            flickr.PhotosGeoSetLocation(flickrId, Convert.ToDouble(model.Latitude), Convert.ToDouble(model.Longitude));

            File.Delete(path);

            return flickrId;
        }
Exemplo n.º 3
0
 public CompletedAuth(FlickrNet.Flickr flickrProxy, string frob)
 {
     InitializeComponent();
     _proxy    = flickrProxy;
     this.Frob = frob;
     Load     += new EventHandler(CompletedAuth_Load);
 }
Exemplo n.º 4
0
        public FlickrSource(IMetadataStore store, IPlacelessconfig configuration, IUserInteraction userInteraction)
        {
            _metadataStore   = store;
            _configuration   = configuration;
            _userInteraction = userInteraction;
            _flickr          = new FlickrNet.Flickr(API_KEY, API_SECRET);
            _flickr.InstanceCacheDisabled = true;
            var token  = _configuration.GetValue(TOKEN_PATH);
            var secret = _configuration.GetValue(SECRET_PATH);

            token  = "";
            secret = "";

            if (string.IsNullOrWhiteSpace(token) || string.IsNullOrWhiteSpace(secret))
            {
                var    requestToken = _flickr.OAuthGetRequestToken("oob");
                string url          = _flickr.OAuthCalculateAuthorizationUrl(requestToken.Token, AuthLevel.Write);
                _userInteraction.OpenWebPage(url);
                string approvalCode = _userInteraction.InputPrompt("Please approve access to your Flickr account and enter the key here:");

                var accessToken = _flickr.OAuthGetAccessToken(requestToken, approvalCode);
                token  = accessToken.Token;
                secret = accessToken.TokenSecret;
                _configuration.SetValue(TOKEN_PATH, token);
                _configuration.SetValue(SECRET_PATH, secret);
            }
            _flickr.OAuthAccessToken       = token;
            _flickr.OAuthAccessTokenSecret = secret;
        }
Exemplo n.º 5
0
    public List <string[]> GetPhotos(string apiKey, string tags)
    {
        FlickrNet.Flickr.CacheDisabled = true;
        FlickrNet.Flickr flickr = new FlickrNet.Flickr(apiKey);

        FlickrNet.PhotoSearchOptions options = new FlickrNet.PhotoSearchOptions();
        options.Tags    = tags;
        options.Extras  = FlickrNet.PhotoSearchExtras.All;
        options.PerPage = 343;
        options.Text    = tags;
        options.TagMode = FlickrNet.TagMode.AllTags;

        List <string[]> photos = new List <string[]>();

        foreach (FlickrNet.Photo photo in flickr.PhotosSearch(options).PhotoCollection)
        {
            photos.Add(new string[] {
                photo.MediumUrl,
                photo.WebUrl,
                photo.Title,
                System.Xml.XmlConvert.ToString(photo.DateTaken, System.Xml.XmlDateTimeSerializationMode.Utc),
                photo.OwnerName,
                photo.Latitude.ToString(),
                photo.Longitude.ToString()
            });
            //                try { photos.Add( new Photo( photo, "{0}" ) ); }
            //                catch { }
        }

        return(photos);
    }
Exemplo n.º 6
0
 public static int GetPagedSetCount(string setId)
 {
     Flickr flickr = new Flickr(ConfigurationManager.AppSettings["apiKey"],
         ConfigurationManager.AppSettings["sharedSecret"]);
     Photoset set = flickr.PhotosetsGetInfo(setId);
     return set.NumberOfPhotos;
 }
        public FlickrDataSource(string username, string apiKey)
        {
            this.Username = username;
            this.ImageSets = new List<FlickrImageSet>();

            _Flickr = new FlickrNet.Flickr(apiKey);
        }
Exemplo n.º 8
0
 public static Flickr getFlickr()
 {
     Flickr f = new Flickr(Secrets.apiKey, Secrets.apiSecret);
     f.OAuthAccessToken = Settings.OAuthAccessToken;
     f.OAuthAccessTokenSecret = Settings.OAuthAccessTokenSecret;
     return f;
 }
Exemplo n.º 9
0
        public FlickrHome()
        {
            this.InitializeComponent();

            _flickr = new FlickrNet.Flickr();
            CheckAlreadyExists();
        }
Exemplo n.º 10
0
        //
        // GET: /Photo/
        public ActionResult Set(string photosetID)
        {
            Flickr flickr = new Flickr(flickrKey, sharedSecret);
            PhotosetPhotoCollection photos = GetPhotosetPhotos(photosetID, flickr);

            return View(photos);
        }
Exemplo n.º 11
0
 public CompletedAuth(FlickrNet.Flickr flickrProxy, string frob)
 {
     InitializeComponent();
     _proxy = flickrProxy;
     this.Frob = frob;
     Load += new EventHandler(CompletedAuth_Load);
 }
Exemplo n.º 12
0
 public FlickrPhoto GetOnePhotoInfoFromFlickr(string photoId)
 {
     Flickr flickr = new Flickr(_apiKey, _secret);
     flickr.InstanceCacheDisabled = true;
     PhotoInfo photoInfo = new PhotoInfo();
     FlickrPhoto flickrPhoto = new FlickrPhoto();
     try
     {
         photoInfo = flickr.PhotosGetInfo(photoId);
         flickrPhoto.PictureId = photoInfo.PhotoId;
         flickrPhoto.OwnerName = !string.IsNullOrWhiteSpace(photoInfo.OwnerRealName) ? photoInfo.OwnerRealName : photoInfo.OwnerUserName;
         flickrPhoto.Title = photoInfo.Title;
         flickrPhoto.Description = photoInfo.Description;
         flickrPhoto.AvailablePublic = photoInfo.IsPublic;
         flickrPhoto.SmallImageUrl = photoInfo.Small320Url;
     }
     catch (Exception ex)
     {
         if (ex is PhotoNotFoundException)
         {
             flickrPhoto.AvailablePublic = false;
         }
     }
     return flickrPhoto;
 }
Exemplo n.º 13
0
 public static void OpenAuthURL()
 {
     Flickr flickr = new Flickr(ApiKey, SharedSecret);
     frob = flickr.AuthGetFrob();
     AuthUrl = flickr.AuthCalcUrl(frob, AuthLevel.Write);
     System.Diagnostics.Process.Start(AuthUrl);
 }
Exemplo n.º 14
0
 public IEnumerable<FlickrImage> GetImages(string tags)
 {
     Flickr.CacheDisabled = true;
     var flickr = new Flickr("340b341adedd9b2613d5c447c4541e0f");
     flickr.InstanceCacheDisabled = true;
     var options = new PhotoSearchOptions { Tags = tags, PerPage = 2  };
     var photos = flickr.PhotosSearch(options);
     return photos.Select(i =>
     {
         using (var client = new WebClient())
         {
             var data = client.DownloadData(i.Medium640Url);
             using (var memoryStream = new MemoryStream(data))
             {
                 var bitmap = new Bitmap(memoryStream);
                 return new FlickrImage
                            {
                                Url = i.Medium640Url,
                                Image = new Bitmap(bitmap),
                                Encoded = Convert.ToBase64String(memoryStream.ToArray())
                            };
             }
         }
     });
 }
        private string UploadToFlickr(TideTrackerInputModel model)
        {
            string flickrId = string.Empty;

            var flickr = new Flickr(FlickrApiKey, FlickrApiSecret);

            //var oauthRequestToken = flickr.OAuthGetRequestToken("http://www.witnesskingtides.com/");
            //var ouathRequestToken = flickr.OAuthGetRequestToken("http://www.flickr.com/auth-72157638432779974");

            var client = new WebClient();
            var miniToken = client.DownloadString("http://www.flickr.com/auth-72157638432779974");

            //flickr = new Flickr(FlickrApiKey, FlickrApiSecret, oauthRequestToken.Token);

            //var auth = flickr.OAuthGetAccessToken(oauthRequestToken.Token, oauthRequestToken.TokenSecret, "72157638432779974");

            //var auth = flickr.AuthOAuthGetAccessToken();
            //using (var memoryStream = new MemoryStream())
            //{
            //    memoryStream.Write(model.Photo, 0, model.Photo.Length);

            //    flickrId = flickr.UploadPicture(memoryStream, model.FileName, null, model.Description, null, true, true, true, ContentType.Photo, SafetyLevel.None, HiddenFromSearch.Visible);
            //}

            return flickrId;
        }
Exemplo n.º 16
0
 public PhotoDetails(string path)
 {
     this.components = null;
     this.InitializeComponent();
     if (!File.Exists(path))
     {
         throw new Exception("Invalid ConfigFilePath: " + path);
     }
     this._settings    = new Settings(path);
     this.txtTags.Text = this._settings.Tags;
     FlickrNet.Flickr flickr1 = new FlickrNet.Flickr("ab782e182b4eb406d285211811d625ff", "b080496c05335c3d", this._settings.Token);
     try
     {
         Photosets photosets1 = flickr1.PhotosetsGetList();
         foreach (Photoset photoset1 in photosets1.PhotosetCollection)
         {
             PhotoSetItem item1 = new PhotoSetItem(photoset1.PhotosetId, photoset1.Title);
             this.cboPhotoSets.Items.Add(item1);
             if (photoset1.PhotosetId == this._settings.PhotoSet)
             {
                 this.cboPhotoSets.SelectedItem = item1;
             }
         }
     }
     catch (FlickrException exception1)
     {
         MessageBox.Show("There was a problem in communicating with Flickr via the Flickr API.  " + exception1.Message);
     }
 }
Exemplo n.º 17
0
 public static Flickr GetAuthInstance()
 {
     var f = new Flickr(ApiKey, SharedSecret);
     f.OAuthAccessToken = OAuthToken;
     f.OAuthAccessTokenSecret = OAuthTokenSecret;
     return f;
 }
Exemplo n.º 18
0
        public void Login()
        {
            // Create Flickr instance
            m_flickr = new Flickr(API_KEY, SECRET);

            m_frob = m_flickr.AuthGetFrob();

            string flickrUrl = m_flickr.AuthCalcUrl(m_frob, AuthLevel.Write);

            // The following line will load the URL in the users default browser.
            System.Diagnostics.Process.Start(flickrUrl);

            bool bIsAuthorized = false;
            m_auth = new Auth();

            // do nothing until flickr authorizes.
            while (!bIsAuthorized)
            {
                try
                {
                    m_auth = m_flickr.AuthGetToken(m_frob);
                    m_flickr.AuthToken = m_auth.Token;
                }
                catch (FlickrException ex)
                {
                    ;
                }

                if (m_flickr.IsAuthenticated)
                {
                    bIsAuthorized = true;
                }
            }
        }
Exemplo n.º 19
0
 public CompletedAuth(FlickrNet.Flickr flickrProxy, object frob)
 {
     InitializeComponent();
     _proxy = flickrProxy;
     Frob = frob;
     Load += CompletedAuth_Load;
 }
Exemplo n.º 20
0
 private void buttonStart_Click(object sender, EventArgs e)
 {
     // Create Flickr instance
     Flickr flickr = new Flickr(Program.ApiKey, Program.SharedSecret);
     try
     {
         // use the temporary Frob to get the authentication
         Auth auth = flickr.AuthGetToken(Program.tempFrob);
         // Store this Token for later usage,
         // or set your Flickr instance to use it.
         string info = "Authentification réussie\n" +
             "Utilisateur identifié: " + auth.User.UserName + "\n" +
             "L'identifiant pour cette session est " + auth.Token + "\n";
         Program.AuthToken = auth.Token;
         Program.Username = auth.User.UserName;
         MessageBox.Show(info, "Identification Flickr",
           MessageBoxButtons.OK, MessageBoxIcon.Information);
         Program.WriteConfig();
         Hide();
         var main_window = new MainForm();
         main_window.Show();
     }
     catch (FlickrException ex)
     {
         // If user did not authenticate your application
         // then a FlickrException will be thrown.
         string info = "L'authentification a échoué:\n" + ex.Message;
         MessageBox.Show(info, "Identification Flickr",
           MessageBoxButtons.OK, MessageBoxIcon.Error);
         // Quit application
         Application.Exit();
     }
 }
        public EffectGraphHomeView()
        {
            this.InitializeComponent();

            _flickr = new FlickrNet.Flickr(apiKey, apiSecret);

            PopupService.Init(layoutRoot);
 

            LoggingService.LogInformation("Showing splash screeen", "Views.HomeView");
            _vm = new HomeViewModel();
            _vm.Load();
            this.DataContext = _vm;

            //_vm.ShowLoginCommand.Execute(null);


            try
            {
                
                //Messenger.Default.Register<GeneralSystemWideMessage>(this, DoGeneralSystemWideMessageCallback);

                
            }
            catch { }


            //AppDatabase.Current.DeleteProjects(SessionID);


        }
Exemplo n.º 22
0
        public FlickrWrapper(Settings settings)
        {
            if (settings == null) throw new ArgumentNullException("settings");

            Settings = settings;
            Flickr = new Flickr(Settings.FlickrApiKey);
        }
Exemplo n.º 23
0
        public void ShowPic()
        {
            if (CheckNetwork() == true)
            {
                MessageBox.Show("A network connection can not be established.\r\nPlease press refresh or check your network settings.");
                return;
            }
            else
            {
                picList.ItemsSource = "";

                try
                {
                    //to use Flickr go to Project-> Manage NuGet Packages-> Search "Flickr" -> install for windows phone 7


                    Flickr flickr = new Flickr("9a03824af501c318fec232146c6b1d05", "cd5cbd132cfbc60c"); // Authorise by api key and secret
                    PhotoSearchOptions options = new PhotoSearchOptions();
                    options.Tags = App.selectedCountryDetails.CountryCapital.ToString(); //give a key word to search

                    flickr.PhotosSearchAsync(options, (pictures) =>
                    {
                        picList.Dispatcher.BeginInvoke(new Action(delegate()
                        {
                            picList.ItemsSource = pictures.Result; //binding source to listbox
                        }));
                    });
                }
                catch (Exception e)
                {
                    MessageBox.Show("An error occured. Please exit app and try again.\r\nError Details: " + e.Message.ToString());
                }
            }
        }
Exemplo n.º 24
0
        public FlickrHome()
        {
            this.InitializeComponent();

            _flickr = new FlickrNet.Flickr();
            CheckAlreadyExists();
        }
Exemplo n.º 25
0
        public EffectGraphHomeView()
        {
            this.InitializeComponent();

            _flickr = new FlickrNet.Flickr(apiKey, apiSecret);

            PopupService.Init(layoutRoot);


            LoggingService.LogInformation("Showing splash screeen", "Views.HomeView");
            _vm = new HomeViewModel();
            _vm.Load();
            this.DataContext = _vm;

            //_vm.ShowLoginCommand.Execute(null);


            try
            {
                //Messenger.Default.Register<GeneralSystemWideMessage>(this, DoGeneralSystemWideMessageCallback);
            }
            catch { }


            //AppDatabase.Current.DeleteProjects(SessionID);
        }
Exemplo n.º 26
0
 public searchForm()
 {
     InitializeComponent();
     flickr = new Flickr();
     flickr.ApiKey = "02d9d42e5874595ec784899f266eb706";
     flickr.ApiSecret = "bc63ffe27560e18b";
 }
Exemplo n.º 27
0
        public static PhotosetCollection GetPhotoSetsByUser(string userId)
        {
            Flickr flickr = new Flickr(ConfigurationManager.AppSettings["apiKey"],
                ConfigurationManager.AppSettings["sharedSecret"]);

            return flickr.PhotosetsGetList(userId);
        }
Exemplo n.º 28
0
        public static PhotoInfo GetPhotoInfo(string photoId)
        {
            Flickr flickr = new Flickr(ConfigurationManager.AppSettings["apiKey"],
                ConfigurationManager.AppSettings["sharedSecret"]);

            return flickr.PhotosGetInfo(photoId);
        }
Exemplo n.º 29
0
 private void ButtonPhoto_Click(object sender, EventArgs e)
 {
     var flickr = new Flickr(Program.ApiKey, Program.SharedSecret, Program.AuthToken);
     // Referrers
     DateTime day = DateTime.Today;
     var statfile = new System.IO.StreamWriter("stats_dom.csv");
     var reffile = new System.IO.StreamWriter("stats_referrers.csv");
     while (day > Program.LastUpdate)
     {
         try
         {
             var s = flickr.StatsGetPhotoDomains(day, 1, 100);
             day -= TimeSpan.FromDays(1);
             StatusLabel.Text = "Chargement des domaines " + day.ToShortDateString();
             Application.DoEvents();
             statfile.Write(Utility.toCSV(s, day.ToShortDateString()));
             foreach (StatDomain dom in s)
             {
                 var r = flickr.StatsGetPhotoReferrers(day, dom.Name, 1, 100);
                 reffile.Write(Utility.toCSV(r, day.ToShortDateString() + ";" + dom.Name));
             }
         }
         catch (FlickrApiException ex)
         {
             MessageBox.Show("Erreur lors du chargement des domaines référents du "
                 + day.ToShortDateString() + " : " + ex.OriginalMessage,
                 "Erreur", MessageBoxButtons.OK);
             break;
         }
     }
     statfile.Close();
 }
Exemplo n.º 30
0
        public static FoundUser GetUserInfo(string userName)
        {
            Flickr flickr = new Flickr(ConfigurationManager.AppSettings["apiKey"],
            ConfigurationManager.AppSettings["sharedSecret"]);

            return flickr.PeopleFindByUserName(userName);
        }
Exemplo n.º 31
0
        public void CheckApiKeyDoesNotThrowWhenPresent()
        {
            Flickr f = new Flickr();
            f.ApiKey = "X";

            Assert.DoesNotThrow(f.CheckApiKey);
        }
Exemplo n.º 32
0
 public static void GetDataResponseAsync(Flickr flickr, string baseUrl, Dictionary<string, string> parameters, Action<FlickrResult<string>> callback)
 {
     if (parameters.ContainsKey("oauth_consumer_key"))
     FlickrResponder.GetDataResponseOAuthAsync(flickr, baseUrl, parameters, callback);
       else
     FlickrResponder.GetDataResponseNormalAsync(flickr, baseUrl, parameters, callback);
 }
Exemplo n.º 33
0
 public AccountController(IBoekService bs)
 {
     this.bs = bs;
     flickr = MvcApplication.flickr;
     if (flickr == null) flickr = FlickrApiManager.GetInstance();
 
 }
Exemplo n.º 34
0
 public static string GetDataResponse(Flickr flickr, string baseUrl, Dictionary<string, string> parameters)
 {
     if (parameters.ContainsKey("oauth_consumer_key"))
     return FlickrResponder.GetDataResponseOAuth(flickr, baseUrl, parameters);
       else
     return FlickrResponder.GetDataResponseNormal(flickr, baseUrl, parameters);
 }
Exemplo n.º 35
0
        public List<Photo> Read(int page = 1)
        {
            var photos = new List<Photo>();
            var flickr = new FlickrNet.Flickr(_apiToken, _secretKey);
            
            PhotoCollection col = flickr.FavoritesGetPublicList(_userid, DateTime.Now.AddYears(-10), DateTime.Now,
                                                                PhotoSearchExtras.All, page, _perPage);

            foreach (FlickrNet.Photo item in col)
            {
                var author = new Author
                    {
                        Name = item.OwnerName,
                        ID = item.UserId,
                        URL = string.Format("https://www.flickr.com/photos/{0}/", item.UserId)
                    };
                photos.Add(new Photo
                    {
                        Title = item.Title,
                        URL = item.WebUrl,
                        Path = item.DoesLargeExist ? item.LargeUrl : item.MediumUrl,
                        PublishedDate = item.DateTaken,
                        Author = author
                    });
            }
            return photos;
        }
Exemplo n.º 36
0
        private void BGFindPhotosets(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker worker = sender as BackgroundWorker;

            FlickrNet.Flickr f = FlickrManager.GetFlickrAuthInstance();
            if (f == null)
            {
                BGErrorMessage = "You must authenticate before you can download data from Flickr.";
                return;
            }

            try
            {
                int page    = 1;
                int perPage = 500;
                FlickrNet.PhotosetCollection photoSets      = new FlickrNet.PhotosetCollection();
                FlickrNet.PhotoSearchExtras  PhotosetExtras = 0;
                do
                {
                    photoSets = f.PhotosetsGetList(SearchAccountUser.UserId, page, perPage, PhotosetExtras);
                    foreach (FlickrNet.Photoset ps in photoSets)
                    {
                        PhotosetList.Add(new Photoset(ps));
                        int index = PhotosetList.Count - 1;
                        PhotosetList[index].OriginalSortOrder = index;
                    }
                    page = photoSets.Page + 1;
                }while (page <= photoSets.Pages);
            }
            catch (FlickrNet.FlickrException ex)
            {
                BGErrorMessage = "Album search failed. Error: " + ex.Message;
                return;
            }
        }
Exemplo n.º 37
0
	public List<string[]> GetPhotos( string apiKey, string tags )
	{
		FlickrNet.Flickr.CacheDisabled = true;
		FlickrNet.Flickr flickr = new FlickrNet.Flickr( apiKey );

		FlickrNet.PhotoSearchOptions options = new FlickrNet.PhotoSearchOptions();
		options.Tags = tags;
		options.Extras = FlickrNet.PhotoSearchExtras.All;
		options.PerPage = 343;
		options.Text = tags;
		options.TagMode = FlickrNet.TagMode.AllTags;

		List<string[]> photos = new List<string[]>();

		foreach ( FlickrNet.Photo photo in flickr.PhotosSearch( options ).PhotoCollection )
		{
			photos.Add( new string[] {
                    photo.MediumUrl,
                    photo.WebUrl,
                    photo.Title,
                    System.Xml.XmlConvert.ToString( photo.DateTaken, System.Xml.XmlDateTimeSerializationMode.Utc ),
                    photo.OwnerName,
                    photo.Latitude.ToString(),
                    photo.Longitude.ToString() } );
			//                try { photos.Add( new Photo( photo, "{0}" ) ); }
			//                catch { }
		}

		return photos;
	}
Exemplo n.º 38
0
 public UploadPool(string tags)
 {
     UploadTags = tags;
     locker     = new object();
     taskQ      = new Queue <IFileItem> ();
     uploaders  = new Thread [WorkerCount];
     flickr     = new FlickrNet.Flickr(AccountConfig.ApiKey, AccountConfig.ApiSecret, AccountConfig.AuthToken);
 }
Exemplo n.º 39
0
        private void linkLabel2_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            Auth auth1 = new FlickrNet.Flickr("ab782e182b4eb406d285211811d625ff", "b080496c05335c3d").AuthGetToken(this._frob);

            this._settings.Token    = auth1.Token;
            this.linkLabel2.Visible = false;
            MessageBox.Show("Authorization complete!");
        }
Exemplo n.º 40
0
        public DefaultViewModel()
        {
            apiKey    = AppService.AppSetting.FlickrKey;
            apiSecret = AppService.AppSetting.FlickrSecret;

            _flickr  = new FlickrNet.Flickr(apiKey, apiSecret);
            _twitter = new FlickrNet.Twitter(apiKey2, apiSecret2);
        }
Exemplo n.º 41
0
        private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            FlickrNet.Flickr flickr1 = new FlickrNet.Flickr("ab782e182b4eb406d285211811d625ff", "b080496c05335c3d");
            this._frob = flickr1.AuthGetFrob();
            string text1 = flickr1.AuthCalcUrl(this._frob, AuthLevel.Delete);

            Process.Start(text1);
            this.linkLabel1.Visible = false;
            this.linkLabel2.Visible = true;
        }
Exemplo n.º 42
0
    public FlickrClient(ApiSecretSettings apiSecretSettings)
    {
        var settings = apiSecretSettings.Flickr;

        _flickr = new FlickrNet.Flickr(settings.ApiKey, settings.ApiSecret)
        {
            OAuthAccessToken       = settings.Token,
            OAuthAccessTokenSecret = settings.TokenSecret
        };
    }
Exemplo n.º 43
0
        public PhotoDetails(FlickrNet.Flickr flickr, FlickrSettings settings)
        {
            Tracing.Trace("PhotoDetails::ctor");
            this.components = null;
            this.InitializeComponent();
            this._settings = settings;

            this.txtTags.Text = settings.MostRecentTags;
            this._flickr      = flickr;
            LoadPhotosets(false);
        }
Exemplo n.º 44
0
 protected virtual void OnCompleteBtnClicked(object sender, EventArgs e)
 {
     try {
         Auth auth = flickr.AuthGetToken(Frob);
         AuthToken = auth.Token;
         Username  = auth.User.Username;
         flickr    = new FlickrNet.Flickr(ApiKey, ApiSecret, AuthToken);
         SetBtnStateComplete();
     } catch (FlickrNet.FlickrException ex) {
         Console.Error.WriteLine(ex);
     }
 }
Exemplo n.º 45
0
        protected virtual void OnAuthBtnClicked(object sender, EventArgs e)
        {
            flickr = new FlickrNet.Flickr(ApiKey, ApiSecret);
            Frob   = flickr.AuthGetFrob();
            Services.Environment.OpenUrl(flickr.AuthCalcUrl(Frob, AuthLevel.Write));
            Widget image = auth_btn.Image;

            auth_btn.Label    = AddinManager.CurrentLocalizer.GetString("Click to complete authorization");
            auth_btn.Image    = image;
            auth_btn.Clicked -= new EventHandler(OnAuthBtnClicked);
            auth_btn.Clicked += new EventHandler(OnCompleteBtnClicked);
        }
Exemplo n.º 46
0
        /// <summary>
        /// Gets a data response for the given base url and parameters,
        /// either using OAuth or not depending on which parameters were passed in.
        /// </summary>
        /// <param name="flickr">The current instance of the <see cref="Flickr"/> class.</param>
        /// <param name="hashCall"></param>
        /// <param name="baseUrl">The base url to be called.</param>
        /// <param name="parameters">A dictionary of parameters.</param>
        /// <param name="callback"></param>
        /// <returns></returns>
        public static async Task <FlickrResult <string> > GetDataResponseAsync(Flickr flickr, string hashCall, string baseUrl, Dictionary <string, string> parameters)
        {
            bool oAuth = parameters.ContainsKey("oauth_consumer_key");

            if (oAuth)
            {
                return(await GetDataResponseOAuthAsync(flickr, hashCall, baseUrl, parameters));
            }
            else
            {
                return(await GetDataResponseNormalAsync(flickr, hashCall, baseUrl, parameters));
            }
        }
Exemplo n.º 47
0
 public AccountConfig()
 {
     Build();
     if (!String.IsNullOrEmpty(AuthToken))
     {
         flickr = new FlickrNet.Flickr(ApiKey, ApiSecret, AuthToken);
         SetBtnStateComplete();
     }
     else
     {
         flickr = new FlickrNet.Flickr(ApiKey, ApiSecret);
     }
 }
Exemplo n.º 48
0
        /// <summary>
        /// Gets a data response for the given base url and parameters,
        /// either using OAuth or not depending on which parameters were passed in.
        /// </summary>
        /// <param name="flickr">The current instance of the <see cref="Flickr"/> class.</param>
        /// <param name="baseUrl">The base url to be called.</param>
        /// <param name="parameters">A dictionary of parameters.</param>
        /// <param name="callback"></param>
        /// <returns></returns>
        public static void GetDataResponseAsync(Flickr flickr, string baseUrl, Dictionary <string, string> parameters, Action <FlickrResult <string> > callback)
        {
            bool oAuth = parameters.ContainsKey("oauth_consumer_key");

            if (oAuth)
            {
                GetDataResponseOAuthAsync(flickr, baseUrl, parameters, callback);
            }
            else
            {
                GetDataResponseNormalAsync(flickr, baseUrl, parameters, callback);
            }
        }
Exemplo n.º 49
0
        /// <summary>
        /// Gets a data response for the given base url and parameters,
        /// either using OAuth or not depending on which parameters were passed in.
        /// </summary>
        /// <param name="flickr">The current instance of the <see cref="Flickr"/> class.</param>
        /// <param name="baseUrl">The base url to be called.</param>
        /// <param name="parameters">A dictionary of parameters.</param>
        /// <returns></returns>
        public static string GetDataResponse(Flickr flickr, string baseUrl, Dictionary <string, string> parameters)
        {
            bool oAuth = parameters.ContainsKey("oauth_consumer_key");

            if (oAuth)
            {
                return(GetDataResponseOAuth(flickr, baseUrl, parameters));
            }
            else
            {
                return(GetDataResponseNormal(flickr, baseUrl, parameters));
            }
        }
Exemplo n.º 50
0
 public SplashVM()
 {
     _flickr = new FlickrNet.Flickr();
     Tabs.Add(new Tab()
     {
         Name = "Your Favourites", IsSelected = true
     });
     Tabs.Add(new Tab()
     {
         Name = "Public"
     });
     LoadMessangerRegistrations();
     GetAPIData();
     PopulatePassportData();
 }
Exemplo n.º 51
0
        public FlickrRemote(string token, Service service)
        {
            if (string.IsNullOrEmpty(token))
            {
                flickr     = new FlickrNet.Flickr(service.ApiKey, service.Secret);
                this.token = null;
            }
            else
            {
                flickr     = new FlickrNet.Flickr(service.ApiKey, service.Secret, token);
                this.token = token;
            }

            flickr.CurrentService = service.Id;
        }
Exemplo n.º 52
0
        public FlickrRemote(string token, Service service)
        {
            if (token == null || token.Length == 0)
            {
                this.flickr = new FlickrNet.Flickr(service.ApiKey, service.Secret);
                this.token  = null;
            }
            else
            {
                this.flickr = new FlickrNet.Flickr(service.ApiKey, service.Secret, token);
                this.token  = token;
            }

            this.flickr.CurrentService = service.Id;
        }
Exemplo n.º 53
0
        public FlickrRemote(OAuthAccessToken token, Service service)
        {
            if (token == null)
            {
                flickr           = new FlickrNet.Flickr(service.ApiKey, service.Secret);
                this.accessToken = null;
            }
            else
            {
                flickr                        = new FlickrNet.Flickr(service.ApiKey, service.Secret, token.Token);
                this.accessToken              = token;
                flickr.OAuthAccessToken       = token.Token;
                flickr.OAuthAccessTokenSecret = token.TokenSecret;
            }

            flickr.CurrentService = service.Id;
        }
Exemplo n.º 54
0
        internal static FlickrNet.FoundUser FindUserByEmailOrName(FlickrNet.Flickr flickrProxy, string criteria)
        {
            FlickrNet.FoundUser user;

            Regex rxp = new Regex("(?<user>[^@]+)@(?<host>.+)");

            if (rxp.IsMatch(criteria))
            {
                user = flickrProxy.PeopleFindByEmail(criteria);
            }
            else
            {
                user = flickrProxy.PeopleFindByUsername(criteria);
            }

            return(user);
        }
Exemplo n.º 55
0
        internal static FlickrNet.Flickr GetFlickrProxy()
        {
            FlickrNet.Flickr.CacheDisabled = true;
            FlickrNet.Flickr fproxy = null;

            System.Resources.ResourceManager mgr = new System.Resources.ResourceManager(typeof(SmilingGoat.WindowsLiveWriter.Flickr.Properties.Resources));
            fproxy = new FlickrNet.Flickr(mgr.GetString("ApiKey"), mgr.GetString("SharedSecret"));

            // Leverage proxy settings if they are there.
            System.Net.WebProxy proxySettings = (System.Net.WebProxy)WindowsLive.Writer.Api.PluginHttpRequest.GetWriterProxy();
            if (proxySettings != null)
            {
                fproxy.Proxy = proxySettings;
            }

            return(fproxy);
        }
Exemplo n.º 56
0
        private static void GetDataResponseOAuthAsync(Flickr flickr, string baseUrl, Dictionary<string, string> parameters, Action<FlickrResult<string>> callback)
        {
            string method = "POST";

            // Remove api key if it exists.
            if (parameters.ContainsKey("api_key")) parameters.Remove("api_key");
            if (parameters.ContainsKey("api_sig")) parameters.Remove("api_sig");

            // If OAuth Access Token is set then add token and generate signature.
            if (!String.IsNullOrEmpty(flickr.OAuthAccessToken) && !parameters.ContainsKey("oauth_token"))
            {
                parameters.Add("oauth_token", flickr.OAuthAccessToken);
            }
            if (!String.IsNullOrEmpty(flickr.OAuthAccessTokenSecret) && !parameters.ContainsKey("oauth_signature"))
            {
                string sig = flickr.OAuthCalculateSignature(method, baseUrl, parameters, flickr.OAuthAccessTokenSecret);
                parameters.Add("oauth_signature", sig);
            }

            // Calculate post data, content header and auth header
            string data = OAuthCalculatePostData(parameters);
            string authHeader = OAuthCalculateAuthHeader(parameters);

            // Download data.
            try
            {
                DownloadDataAsync(method, baseUrl, data, PostContentType, authHeader, callback);
            }
            catch (WebException ex)
            {
                //if (ex.Status != WebExceptionStatus.ProtocolError) throw;

                HttpWebResponse response = ex.Response as HttpWebResponse;
                if (response == null) throw;

                if (response.StatusCode != HttpStatusCode.BadRequest && response.StatusCode != HttpStatusCode.Unauthorized) throw;

                using (StreamReader responseReader = new StreamReader(response.GetResponseStream()))
                {
                    string responseData = responseReader.ReadToEnd();
                    responseReader.Close();

                    throw new OAuthException(responseData, ex);
                }
            }
        }
Exemplo n.º 57
0
        private static void GetDataResponseNormalAsync(Flickr flickr, string baseUrl, Dictionary<string, string> parameters, Action<FlickrResult<string>> callback)
        {
            string method = flickr.CurrentService == SupportedService.Zooomr ? "GET" : "POST";

            string data = String.Empty;

            foreach (var k in parameters)
            {
                data += k.Key + "=" + Uri.EscapeDataString(k.Value) + "&";
            }

            if (method == "GET" && data.Length > 2000) method = "POST";

            if (method == "GET")
                DownloadDataAsync(method, baseUrl + "?" + data, null, null, null, callback);
            else
                DownloadDataAsync(method, baseUrl, data, PostContentType, null, callback);
        }
Exemplo n.º 58
0
        public override void CreateContentFromUrl(string url, ref string title, ref string newContent)
        {
            Match m = Regex.Match(url, PHOTO_REGEX_URL);

            if (!m.Success)
            {
                base.CreateContentFromUrl(url, ref title, ref newContent);
            }
            else
            {
                string photoId = m.Groups["id"].Value;

                // get photo
                FlickrNet.Flickr flickrProxy = FlickrPluginHelper.GetFlickrProxy();

                FlickrNet.PhotoInfo photo = flickrProxy.PhotosGetInfo(photoId);

                title      = photo.Title;
                newContent = string.Format("<p><a href=\"{0}\" title=\"{2}\"><img alt=\"{2}\" border=\"0\" src=\"{1}\"></a></p>", photo.WebUrl, photo.MediumUrl, HtmlServices.HtmlEncode(photo.Title));
            }
        }
Exemplo n.º 59
0
        private void AddPhotoToList(FlickrNet.Flickr f, FlickrNet.Photo flickrPhoto, Photoset photoset)
        {
            // Filter by date, if filter option enabled and date taken is known.
            if (!Settings.FilterByDate ||
                flickrPhoto.DateTakenUnknown ||
                (flickrPhoto.DateTaken.Date >= Settings.StartDate && flickrPhoto.DateTaken.Date <= Settings.StopDate))
            {
                Photo photo = new Photo(flickrPhoto, photoset);
                PhotoList.Add(photo);

                // Get the photo info to get the raw tags, and put them into the photo object.
                // The raw tags are as uploaded or entered -- with spaces, punctuation, and
                // upper/lower case.
                FlickrNet.PhotoInfo info = f.PhotosGetInfo(flickrPhoto.PhotoId);
                photo.Tags.Clear();
                for (int i = 0; i < info.Tags.Count; i++)
                {
                    photo.Tags.Add(info.Tags[i].Raw);
                }
            }
        }
Exemplo n.º 60
0
        public static string GetAuthoriseURL(out string err)
        {
            err = "";
            try
            {
                MainForm.Conf.Cloud.Flickr = "";

                _service      = null;
                _requestToken = Service.OAuthGetRequestToken("oob");

                string url = Service.OAuthCalculateAuthorizationUrl(_requestToken.Token, AuthLevel.Write);
                _gottoken = false;
                return(url);
            }
            catch (Exception ex)
            {
                err = ex.Message;
                Logger.LogException(ex, "Flickr");
                return("");
            }
        }