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


C# Flickr.AuthCheckToken方法代码示例

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


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

示例1: CheckAuthenticationToken

	    protected Auth CheckAuthenticationToken(IAuthenticationSettings authenticationSettings)
		{
			if (string.IsNullOrEmpty(authenticationSettings.FlickrAuthToken))
			{
				throw new Exception("No Flickr AuthToken!");
			}

			Flickr.CacheTimeout = new TimeSpan(1, 0, 0, 0, 0);

			var flickrService = new Flickr(authenticationSettings.FlickrApiKey, authenticationSettings.FlickrApiSecret, authenticationSettings.FlickrAuthToken);
			var authenticationToken = flickrService.AuthCheckToken(authenticationSettings.FlickrAuthToken);

			return authenticationToken;
		}
开发者ID:taliesins,项目名称:talifun-commander,代码行数:14,代码来源:ExecuteFlickrUploaderWorkflowMessageHandlerBase.cs

示例2: 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

示例3: 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

示例4: Connect

 /// <summary>
 /// uses authtoken from config and tries to connect. if there is any error throw exception.
 /// </summary>
 public void Connect()
 {
     _flickrObj = CreateFlickr();
     Auth authorization = _flickrObj.AuthCheckToken(_flickrObj.AuthToken);
     string userId = authorization.User.UserId;
 }
开发者ID:aviatgithub,项目名称:FlickrBulkUploader,代码行数:9,代码来源:FlickrProxy.cs

示例5: ReadConfig

        // Lecture de la configuration
        static void ReadConfig()
        {
            string config_file = "config.xml";
            if (!System.IO.File.Exists(config_file))
            {
                var newconf = new System.Xml.XmlTextWriter(config_file, null);
                newconf.WriteStartDocument();
                newconf.WriteStartElement("config");
                newconf.WriteElementString("last_update", "0");
                newconf.WriteElementString("auth_token", "");
                newconf.WriteEndElement();
                newconf.WriteEndDocument();
                newconf.Close();
            }

            var conf = new System.Xml.XmlTextReader(config_file);
            string CurrentElement = "";
            while (conf.Read())
            {
                switch(conf.NodeType) {
                    case System.Xml.XmlNodeType.Element:
                        CurrentElement = conf.Name;
                        break;
                    case System.Xml.XmlNodeType.Text:
                    if (CurrentElement == "last_update")
                        LastUpdate = DateTime.Parse(conf.Value);
                    if (CurrentElement == "auth_token")
                        AuthToken = conf.Value;
                        break;
                }
            }
            conf.Close();

            // On vérifie que le token est encore valide
            if (AuthToken.Length > 0)
            {
                var flickr = new Flickr(Program.ApiKey, Program.SharedSecret);
                try
                {
                    Auth auth = flickr.AuthCheckToken(AuthToken);
                    Username = auth.User.UserName;
                }
                catch (FlickrApiException ex)
                {
                    //MessageBox.Show(ex.Message, "Authentification requise",
                    //    MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    AuthToken = "";
                }
            }
        }
开发者ID:remyoudompheng,项目名称:flickrstats,代码行数:51,代码来源:Program.cs

示例6: Main

        static void Main(string[] args)
        {
            StringBuilder errorLog = new StringBuilder();
            errorLog.AppendFormat("Starting Run at {0}\n", DateTime.Now.ToString());
            string baseDir = ConfigurationSettings.AppSettings["LocalDir"].ToString();
            Flickr flickr = new Flickr(ConfigurationSettings.AppSettings["APIKey"].ToString(), ConfigurationSettings.AppSettings["APISecret"].ToString());
            flickr.AuthToken = "";

            Auth auth = flickr.AuthCheckToken("");

            PhotoSearchOptions searchOptions = new PhotoSearchOptions();

            searchOptions.PrivacyFilter = PrivacyFilter.None;
            searchOptions.UserId = auth.User.UserId;
            searchOptions.PerPage = 500;

            PhotoCollection pics = new PhotoCollection();

            WebClient wget = new WebClient();
            searchOptions.Extras |= PhotoSearchExtras.DateTaken | PhotoSearchExtras.OriginalFormat | PhotoSearchExtras.OriginalUrl | PhotoSearchExtras.Description | PhotoSearchExtras.Tags;
            PhotoCollection rev = flickr.PhotosSearch(searchOptions);

            while (rev.Pages >= searchOptions.Page)

            {
                foreach(Photo pic in rev){

                        //We have a picture.
                        string year = pic.DateTaken.Year.ToString("0000");
                        string month = pic.DateTaken.Month.ToString("00");
                        string day = pic.DateTaken.Day.ToString("00");
                        //  Does the directory Exist
                        //      No
                        string directory = String.Format("{0}{1}\\{2}\\{3}\\", baseDir, year, month, day);
                        try
                        {
                        if (!Directory.Exists(directory))
                        {
                            Directory.CreateDirectory(directory);
                        }

                        string fileName = string.Format("{0}.{1}", pic.PhotoId, pic.OriginalFormat);

                        string finalDestination = String.Format("{0}{1}", directory, fileName);
                        if (!File.Exists(finalDestination))
                        {

                            wget.DownloadFile(pic.OriginalUrl, finalDestination);
                            FileInfo fi = new FileInfo(finalDestination);
                            if (fi.Length < 10000)
                            {
                                //This shoudl catch file unavailable
                                throw new Exception("File size is too small");
                            }

                            StreamWriter dataFile = new StreamWriter(String.Format("{0}{1}.xml", directory, fileName));

                            StringBuilder meta = new StringBuilder();
                            meta.AppendFormat("<xml>\n\t<file>{0}</file>\n\t<title>{1}</title>\n\t<description>{2}</description>\n\t<dateTaken>{3}</dateTaken>\n\t<tags>", fileName, pic.Title, pic.Description, pic.DateTaken.ToString());
                            foreach(String tag in pic.Tags){
                                meta.AppendFormat("\n\t\t<tag>{0}</tag>", tag);
                            }
                            meta.Append("\n\t</tags>\n</xml>");
                            dataFile.Write(meta.ToString());
                            dataFile.Close();
                        }
                    }
                    catch (System.Exception ex)
                    {
                        errorLog.AppendFormat("{0}:{1}:{2}\n", directory, pic.PhotoId, ex.Message);
                    }
                }

                searchOptions.Page = rev.Page + 1;
                rev = flickr.PhotosSearch(searchOptions);
            }
            errorLog.AppendFormat("Finished Run at {0}\n", DateTime.Now.ToString());
            StreamWriter file = new StreamWriter(ConfigurationSettings.AppSettings["LocalDir"].ToString() + "/errors.log");
            file.Write(errorLog.ToString());
            file.Close();
        }
开发者ID:josheschulz,项目名称:FlickrSlurp,代码行数:81,代码来源:Program.cs


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