当前位置: 首页>>代码示例>>C#>>正文


C# Flickr.PhotosSearch方法代码示例

本文整理汇总了C#中FlickrNet.Flickr.PhotosSearch方法的典型用法代码示例。如果您正苦于以下问题:C# Flickr.PhotosSearch方法的具体用法?C# Flickr.PhotosSearch怎么用?C# Flickr.PhotosSearch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FlickrNet.Flickr的用法示例。


在下文中一共展示了Flickr.PhotosSearch方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

        static void Main(string[] args)
        {
            Flickr flickr = new Flickr(FlickrKey.Key, FlickrKey.Secret);
            Auth auth = null;
            if (File.Exists("key.txt"))
            {
                using (var sr = new StreamReader("key.txt"))
                {
                    flickr.OAuthAccessToken = sr.ReadLine();
                    flickr.OAuthAccessTokenSecret = sr.ReadLine();
                }

            }

            if (!string.IsNullOrEmpty(flickr.OAuthAccessToken) &&
                 !string.IsNullOrEmpty(flickr.OAuthAccessTokenSecret))
            {
                auth = flickr.AuthOAuthCheckToken();
                int g = 56;
            }
            else
            {
                var requestToken = flickr.OAuthGetRequestToken("oob");
                var url = flickr.OAuthCalculateAuthorizationUrl(requestToken.Token, AuthLevel.Delete);
                Process.Start(url);

                var verifier = Console.ReadLine();

                OAuthAccessToken accessToken = flickr.OAuthGetAccessToken(requestToken, verifier);
                flickr.OAuthAccessToken = accessToken.Token;
                flickr.OAuthAccessTokenSecret = accessToken.TokenSecret;

                using (var sw = new StreamWriter("key.txt", false))
                {
                    sw.WriteLine(flickr.OAuthAccessToken);
                    sw.WriteLine(flickr.OAuthAccessTokenSecret);
                }

                auth = flickr.AuthOAuthCheckToken();
                int y = 56;
            }

            var baseFolder = @"D:\MyData\Camera Dumps\";

            var ex = new PhotoSearchExtras();
            var p = flickr.PhotosSearch(new PhotoSearchOptions(auth.User.UserId){Extras = PhotoSearchExtras.DateTaken | PhotoSearchExtras.PathAlias, });
            var sets = flickr.PhotosetsGetList();
            foreach (var set in sets)
            {
                var setDir = Path.Combine(baseFolder, set.Title);
                if ( Directory.Exists(setDir) )
                {
                    var setPhotos = flickr.PhotosetsGetPhotos(set.PhotosetId, PhotoSearchExtras.DateTaken | PhotoSearchExtras.MachineTags | PhotoSearchExtras.OriginalFormat | PhotoSearchExtras.DateUploaded);
                    foreach(var setPhoto in setPhotos)
                    {
                        if (Math.Abs((setPhoto.DateUploaded - setPhoto.DateTaken).TotalSeconds) < 60)
                        {
                            // Suspicious
                            int s = 56;
                        }

                        string ext = ".jpg";
                        if (setPhoto.OriginalFormat != "jpg")
                        {
                            int xxx = 56;
                        }
                        var filePath = Path.Combine(setDir, setPhoto.Title + ext);

                        if (!File.Exists(filePath))
                        {
                            // try mov
                            filePath = Path.Combine(setDir, setPhoto.Title + ".mov");

                            if (!File.Exists(filePath))
                            {
                                Console.WriteLine("not found " + filePath);
                            }
                        }

                        Console.WriteLine(filePath);
                        if ( File.Exists(filePath))
                        {
                            DateTime dateTaken;
                            if (!GetExifDateTaken(filePath, out dateTaken))
                            {
                                var fi = new FileInfo(filePath);
                                dateTaken = fi.LastWriteTime;
                            }

                            if (Math.Abs((dateTaken - setPhoto.DateTaken).TotalSeconds) > 10)
                            {
                                int hmmm = 56;
                            }
                        }
                    }
                }
            }
            //@"D:\MyData\Camera Dumps\"

            int z =  56;
//.........这里部分代码省略.........
开发者ID:jjbott,项目名称:SyncTool,代码行数:101,代码来源:Program.cs

示例2: GetImages

 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())
                            };
             }
         }
     });
 }
开发者ID:pebblecode,项目名称:raci,代码行数:25,代码来源:FlickrImageService.cs

示例3: GetPhotos

	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;
	}
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:30,代码来源:Flickr.cs

示例4: FindUserButton_Click

        private void FindUserButton_Click(object sender, EventArgs e)
        {
            // First page of the users photos
            // Sorted by interestingness

            Flickr flickr = new Flickr(ApiKey.Text);
            FoundUser user;
            try
            {
                user = flickr.PeopleFindByUserName(Username.Text);
                OutputTextbox.Text = "User Id = " + user.UserId + "\r\n" + "Username = " + user.UserName + "\r\n";
            }
            catch (FlickrException ex)
            {
                OutputTextbox.Text = ex.Message;
                return;
            }

            PhotoSearchOptions userSearch = new PhotoSearchOptions();
            userSearch.UserId = user.UserId;
            userSearch.SortOrder = PhotoSearchSortOrder.InterestingnessDescending;
            PhotoCollection usersPhotos = flickr.PhotosSearch(userSearch);
            // Get users contacts
            ContactCollection contacts = flickr.ContactsGetPublicList(user.UserId);
            // Get first page of a users favorites
            PhotoCollection usersFavoritePhotos = flickr.FavoritesGetPublicList(user.UserId);
            // Get a list of the users groups
            //PublicGroupInfoCollection usersGroups = flickr.PeopleGetPublicGroups(user.UserId);

            int i = 0;
            foreach (Contact contact in contacts)
            {
                OutputTextbox.Text += "Contact " + contact.UserName + "\r\n";
                if (i++ > 10) break; // only list the first 10
            }

            i = 0;
            //foreach (PublicGroupInfo group in usersGroups)
            //{
            //    OutputTextbox.Text += "Group " + group.GroupName + "\r\n";
            //    if (i++ > 10) break; // only list the first 10
            //}

            i = 0;
            foreach (Photo photo in usersPhotos)
            {
                OutputTextbox.Text += "Interesting photo title is " + photo.Title + " " + photo.WebUrl + "\r\n";
                if (i++ > 10) break; // only list the first 10
            }

            i = 0;
            foreach (Photo photo in usersFavoritePhotos)
            {
                OutputTextbox.Text += "Favourite photo title is " + photo.Title + " " + photo.WebUrl + "\r\n";
                if (i++ > 10) break; // only list the first 10
            }
        }
开发者ID:kenpower,项目名称:flickdownloader,代码行数:57,代码来源:ExampleForm1.cs

示例5: FlickrHandler

        private IEnumerable<ResponseMessage> FlickrHandler(IncomingMessage message, string matchedHandle)
        {
            string searchTerm = message.TargetedText.Substring(matchedHandle.Length).Trim();

            if (string.IsNullOrEmpty(searchTerm))
            {
                yield return message.ReplyToChannel($"Please give me something to search, e.g. {matchedHandle} trains");
            }
            else
            {
                yield return message.IndicateTypingOnChannel();
                string apiKey = _configReader.GetConfigEntry<string>("flickr:apiKey");

                if (string.IsNullOrEmpty(apiKey))
                {
                    _statsPlugin.IncrementState("Flickr:Failed");
                    yield return message.ReplyToChannel("Woops, looks like a Flickr API Key has not been entered. Please ask the admin to fix this");
                }
                else
                {
                    var flickr = new Flickr(apiKey);

                    var options = new PhotoSearchOptions { Tags = searchTerm, PerPage = 50, Page = 1};
                    PhotoCollection photos = flickr.PhotosSearch(options);

                    if (photos.Any())
                    {
                        _statsPlugin.IncrementState("Flickr:Sent");

                        int i = new Random().Next(0, photos.Count);
                        Photo photo = photos[i];
                        var attachment = new Attachment
                        {
                            AuthorName = photo.OwnerName,
                            Fallback = photo.Description,
                            ImageUrl = photo.LargeUrl,
                            ThumbUrl = photo.ThumbnailUrl
                        };

                        yield return message.ReplyToChannel($"Here is your picture about '{searchTerm}'", attachment);
                    }
                    else
                    {
                        _statsPlugin.IncrementState("Flickr:Failed");
                        yield return message.ReplyToChannel($"Sorry @{message.Username}, I couldn't find anything about {searchTerm}");
                    }
                }
            }
        }
开发者ID:noobot,项目名称:Noobot.Toolbox,代码行数:49,代码来源:FlickrMiddleware.cs

示例6: GetImages

        public static void GetImages(string searchTerm)
        {
            Flickr fl = new Flickr("8704e391e50a52774ee2bf393c35b10c");

            PhotoSearchOptions opt = new PhotoSearchOptions();
            opt.Text = searchTerm;
            opt.PerPage = 10;
            opt.Page = 1;
            var photos = fl.PhotosSearch(opt);
            foreach (Photo p in photos)
            {
                System.Drawing.Image img = DownloadImage(p.LargeUrl);

                SurfaceWindow1.AddImage(img, System.Windows.Media.Colors.Transparent);
            }
        }
开发者ID:EmilBechMadsen,项目名称:AEBM-ITU-PSCT-2013,代码行数:16,代码来源:FlickrHandler.cs

示例7: GetPictures

        private void GetPictures(string tag)
        {
            PhotoSearchOptions options = new PhotoSearchOptions();
            options.PerPage = 18;
            options.Page = 1;
            options.SortOrder = PhotoSearchSortOrder.DatePostedDescending;
            options.MediaType = MediaType.Photos;
            options.Extras = PhotoSearchExtras.All;
            options.Tags = tag;

            Flickr flickr = new Flickr(flickrKey, sharedSecret);
            PhotoCollection photos = flickr.PhotosSearch(options);

            ThumbnailsList.DataSource = photos;
            ThumbnailsList.DataBind();
        }
开发者ID:lotfar,项目名称:Asp.net_Flickr-App,代码行数:16,代码来源:WebForm1.aspx.cs

示例8: ApiSpike_GetInfo

        public void ApiSpike_GetInfo()
        {
            var client = new Flickr(Settings.Flickr.ApiKey, Settings.Flickr.SharedSecret);
            client.InstanceCacheDisabled = true;

            var photos = client.PhotosSearch(new PhotoSearchOptions(Settings.Flickr.UserId, "blog"));

            var result = new List<Tuple<string,string>>();

            foreach (var photo in photos)
            {
                var info = client.PhotosGetInfo(photo.PhotoId, photo.Secret);
                result.Add(new Tuple<string, string>(info.Title, info.Description));
            }

            Assert.That(result, Is.Not.Empty);
        }
开发者ID:G-Rad,项目名称:nzblog,代码行数:17,代码来源:FlickrTests.cs

示例9: GetPhotoButton_Click

        private void GetPhotoButton_Click(object sender, EventArgs e)
        {
            Flickr flickr = new Flickr(ApiKey.Text, SharedSecret.Text, AuthToken.Text);

            Auth auth = flickr.AuthCheckToken(AuthToken.Text);

            PhotoSearchOptions options = new PhotoSearchOptions(auth.User.UserId);
            options.SortOrder = PhotoSearchSortOrder.DatePostedDescending;
            options.PerPage = 1;

            PhotoCollection photos = flickr.PhotosSearch(options);

            Flickr.FlushCache(flickr.LastRequest);

            Photo photo = photos[0];

            webBrowser1.Navigate(photo.SmallUrl);

            OldTitle.Text = photo.Title;
            PhotoId.Text = photo.PhotoId;
        }
开发者ID:kenpower,项目名称:flickdownloader,代码行数:21,代码来源:UpdateForm.cs

示例10: ImportSearchResults

        public void ImportSearchResults(Flickr flickr, string userId, string searchTerm)
        {
            var results = flickr.PhotosSearch(new PhotoSearchOptions()
            {
                 SafeSearch = SafetyLevel.Safe,
                 IsCommons = true,
                 Tags = searchTerm,
                 Extras = PhotoSearchExtras.Tags,
                 Page = 0,
                 PerPage = 50
            });
            var user = userRepository.Load(userId);
            foreach (var image in results)
            {
                Console.WriteLine("Found {0} with ({1})", image.Title, string.Join(",", image.Tags.ToArray()));

                Console.WriteLine("Downloading image data");

                WebRequest request = WebRequest.Create(image.MediumUrl);
                Byte[] content = null;
                using (var response = request.GetResponse())
                {
                    content = new Byte[response.ContentLength];
                    var stream = response.GetResponseStream();
                    BinaryReader reader = new BinaryReader(stream);
                    content = reader.ReadBytes((int)response.ContentLength);
                }

                imageUploadService.UploadUserImage(user,
                        image.Title,
                        image.Tags.ToArray(),
                        content);

                Console.WriteLine("Downloaded image data");
            }
            documentSession.SaveChanges();
        }
开发者ID:robashton,项目名称:RavenGallery,代码行数:37,代码来源:FlickrImporter.cs

示例11: FlickrHandler

        private IEnumerable<ResponseMessage> FlickrHandler(IncomingMessage message, string matchedHandle)
        {
            string searchTerm = message.TargetedText.Substring(matchedHandle.Length).Trim();

            if (string.IsNullOrEmpty(searchTerm))
            {
                yield return message.ReplyToChannel($"Please give me something to search, e.g. {matchedHandle} trains");
            }
            else
            {
                yield return message.ReplyToChannel($"Ok, let's find you something about '{searchTerm}'");
                string apiKey = _configReader.GetConfig().Flickr?.ApiKey;

                if (string.IsNullOrEmpty(apiKey))
                {
                    yield return message.ReplyToChannel("Woops, looks like a Flickr API Key has not been entered. Please ask the admin to fix this");
                }
                else
                {
                    var flickr = new Flickr(apiKey);

                    var options = new PhotoSearchOptions { Tags = searchTerm, PerPage = 50, Page = 1};
                    PhotoCollection photos = flickr.PhotosSearch(options);

                    if (photos.Any())
                    {
                        int i = new Random().Next(0, photos.Count);
                        Photo photo = photos[i];
                        yield return message.ReplyToChannel(photo.LargeUrl);
                    }
                    else
                    {
                        yield return message.ReplyToChannel($"Sorry @{message.Username}, I couldn't find anything about {searchTerm}");
                    }
                }
            }
        }
开发者ID:irmbrady,项目名称:noobot,代码行数:37,代码来源:FlickrMiddleware.cs

示例12: Index

        public ActionResult Index(Models.FlickrSearchModel model, string paging)
        {
            string searchText = model.SearchText;
            int curPage = model.Page;
            int nextPage = curPage;

            switch (paging)
            {
                case "next":
                    nextPage++;
                    break;
                case "previous":
                    nextPage--;
                    break;
            }

            Flickr flickr = new Flickr(apiKey);
            var options = new PhotoSearchOptions { Tags = searchText, PerPage = 12, Page = nextPage };
            PhotoCollection photos = flickr.PhotosSearch(options);
            model.Photos = photos;
            model.Page = nextPage;

            return View(model);
        }
开发者ID:ryankmcintyre,项目名称:Project20,代码行数:24,代码来源:HomeController.cs

示例13: Create

        public ActionResult Create(Destino Destino,string Button, Map map)
        {
            var idViaje = Convert.ToInt32(Request["idViaje"]);

            if (Button == "Agregar Destino")
            {
                IRepositorio<Destino> repo = new DestinoRepositorio();
                IRepositorio<Viaje> repoViaje = new ViajeRepositorio();
                Destino.Viaje = repoViaje.GetById(idViaje);
                PhotoSearchOptions options = new PhotoSearchOptions();
                options.Extras |= PhotoSearchExtras.Geo;
                options.Tags = map.Name;
                options.HasGeo = true;
                options.PerPage = 24;
                Flickr flickr = new Flickr("3de826e278b4988011ef0227585a7838", "81a96df44a82b16c");
                photos = flickr.PhotosSearch(options);
                foreach (Photo photo in photos)
                {
                    if (Destino.Url != null)
                    {
                        if (Destino.Url.CompareTo(photo.SmallUrl) == 0)
                        {
                            Destino.Latitud = photo.Latitude;
                            Destino.Longitud = photo.Longitude;
                            Destino.Nombre = photo.Title;
                        }
                    }else
                    {
                        ModelState.AddModelError(string.Empty,"Es Necesario que escoja una foto!");
                        return View();
                    }
                }
                repo.Save(Destino);
                int id2 = idViaje;
                ViewData["idViaje"] = id2;
                return RedirectToAction("Index", "Destino", new { idViaje = id2 });
            }
            else {
                int i = 0;
                PhotoSearchOptions options = new PhotoSearchOptions();
                //options.BoundaryBox = new BoundaryBox(-1.7, 54.9, -1.4, 55.2); // Roughly Newcastle upon Type, England
                //options.BoundaryBox = BoundaryBox.World;
                options.Extras |= PhotoSearchExtras.Geo;
                options.Tags = map.Name;
                options.HasGeo = true;
                options.PerPage = 24;

                Flickr flickr = new Flickr("18ead65365e9b505cc7f97abd38a33fe", "1b0f7df21b450da8");

                photos = flickr.PhotosSearch(options);
                foreach (Photo photo in photos)
                {
                    ViewData["Message"] = String.Format("Lugares de \"{0}\".", map.Name);
                    ViewData.Add(("Message" + i), photo.SmallUrl);
                    i++;
                }
                int id2 = idViaje;
                ViewData["idViaje"] = id2;

                return View();
            }
        }
开发者ID:twisted-proyecto,项目名称:twisted,代码行数:62,代码来源:DestinoController.cs

示例14: PostImage

        public async Task<HttpResponseMessage> PostImage([ValueProvider(typeof(HeaderValueProviderFactory<string>))]
          string sessionKey)
        {
            if (!Request.Content.IsMimeMultipartContent())
            {
                throw new HttpResponseException(HttpStatusCode.UnsupportedMediaType);
            }

            // Read the file

            string root = HttpContext.Current.Server.MapPath("~/App_Data");
            var provider = new MultipartFormDataStreamProvider(root);


                if (!Request.Content.IsMimeMultipartContent())
                {
                    throw new HttpResponseException(HttpStatusCode.UnsupportedMediaType);
                }
                using (var db = new BGNewsDB())
                {
                    var user = db.Users.FirstOrDefault(x => x.SessionKey == sessionKey);
                    if (user == null)
                    {
                        return Request.CreateResponse(HttpStatusCode.Unauthorized);
                    }

                    try
                    {
                        // Read the form data.
                        await Request.Content.ReadAsMultipartAsync(provider);

                        // This illustrates how to get the file names.
                        foreach (MultipartFileData file in provider.FileData)
                        {
                            Trace.WriteLine(file.Headers.ContentDisposition.FileName);
                            Trace.WriteLine("Server file path: " + file.LocalFileName);
                            string fileName = file.LocalFileName;
                            Flickr flickr = new Flickr("8429718a57e817718d524ea6366b5b42", "3504e68e5812b923", "72157635282605625-a5feb0f5a53c4467");
                            var result = flickr.UploadPicture(fileName);
                            System.IO.File.Delete(file.LocalFileName);


                            // Take the image urls from flickr

                            Auth auth = flickr.AuthCheckToken("72157635282605625-a5feb0f5a53c4467");
                            PhotoSearchOptions options = new PhotoSearchOptions(auth.User.UserId);
                            options.SortOrder = PhotoSearchSortOrder.DatePostedDescending;
                            options.PerPage = 1;

                            ICollection<Photo> photos = flickr.PhotosSearch(options);

                            Flickr.FlushCache(flickr.LastRequest);

                            Photo photo = photos.First();
                               user.ProfilePictureUrlMedium = photo.MediumUrl;
                               user.ProfilePictureUrlThumbnail = photo.SquareThumbnailUrl;
                            break;

                        }
                       
                     
                        return Request.CreateResponse(HttpStatusCode.Created);
                    }

                    catch (System.Exception e)
                    {
                        return Request.CreateErrorResponse(HttpStatusCode.InternalServerError, e);
                    }
                }
            
        }
开发者ID:krstan4o,项目名称:katlaTeamProjectTelerik,代码行数:71,代码来源:UsersController.cs

示例15: simmiWorker_DoWork

        // This method takes care of the process heavy stuff. It can report progress and I will use that
        // to load each image.
        private void simmiWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker worker = sender as BackgroundWorker;
            Console.WriteLine("Async backgroundworker started");

            if ((worker.CancellationPending == true))
            {
                Console.WriteLine("if");
                e.Cancel = true;
                // breaks out of the loop, if there is a loop.
                // break;
            }
            else
            {
                Flickr flickr = new Flickr("59c64644ddddc2a52a089131c8ca0933", "b080535e26aa05df");
                FoundUser user = flickr.PeopleFindByUserName("simmisj");
                //FoundUser user = flickr.PeopleFindByUserName("simmisj");

                //PeoplePhotoCollection people = new PeoplePhotoCollection();

                //people = flickr.PeopleGetPhotosOf(user.UserId);

                PhotoSearchOptions options = new PhotoSearchOptions();
                options.UserId = user.UserId; // Your NSID
                options.PerPage = 4; // 100 is the default anyway
                PhotoCollection photos;

                try
                {
                    photos = flickr.PhotosSearch(options);
                    photos.Page = 1;
                }
                catch (Exception ea)
                {
                    //e.Result = "Exception: " + ea;
                    return;
                }

                for (int i = 0; i < photos.Count; i++)
                {
                    // Report progress and pass the picture to the progresschanged method
                    // for the progresschanged method to update the observablecollection.
                    worker.ReportProgress(100, photos[i].Medium640Url);
                    //pictures.Add(photos[i].Medium640Url);

                    // Add the picture to the ObservableCollection.
                    //pictures.Add(photos[i].Medium640Url);
                    //scatterView1.Items.Add(photos[i].ThumbnailUrl);

                }

            }
        }
开发者ID:simmisj,项目名称:MandatoryAssignmentSurface,代码行数:55,代码来源:SurfaceWindow1.xaml.cs


注:本文中的FlickrNet.Flickr.PhotosSearch方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。