private void btnAuth_Click(object sender, EventArgs e) { Flickr flickr = FlickrManager.GetInstance(); // what's "oob" ? // I have tried "flickr-up", then error. hmm... RequestToken = flickr.OAuthGetRequestToken("oob"); String uri = flickr.OAuthCalculateAuthorizationUrl(RequestToken.Token, AuthLevel.Write); System.Diagnostics.Process.Start(uri); }
private String GetPhotoSetID(String Sets) { Flickr f = FlickrManager.GetAuthInstance(); PhotosetCollection photosets = f.PhotosetsGetList(); foreach (Photoset pset in photosets) { if (Sets == pset.Title) { return(pset.PhotosetId); } Console.WriteLine(pset.Title); } return(""); }
private void btnAuthComplete_Click(object sender, EventArgs e) { String verify = txtVerifier.Text; if (String.IsNullOrEmpty(verify)) { MessageBox.Show("認証コードを入力してください"); return; } Flickr flickr = FlickrManager.GetInstance(); try { var Accsesstoken = flickr.OAuthGetAccessToken(RequestToken, verify); txtResult.AppendText("ok\n"); txtResult.AppendText(Accsesstoken.FullName + "\n"); Config.OAuthToken = Accsesstoken; } catch (FlickrApiException ex) { txtResult.AppendText(ex.ToString()); } }
private void bgWorker_DoWork(object sender, DoWorkEventArgs e) { List <PhotoLocal> PhotofileList = GetPhotoPathList(txtPhotoPath.Text); if (PhotofileList == null || PhotofileList.Count == 0) { MessageBox.Show("画像フォルダを指定してください"); return; } String Desc = txtDescription.Text; String Tags = txtTags.Text; String Sets = txtSets.Text; Boolean IsPrivate = false; List <String> PhotoID = new List <String>(); int resize = 100; try { resize = Convert.ToInt32(txtResize.Text); } catch (FormatException ex) { txtResize.AppendText(ex.Message); } if (Directory.Exists(Config.WorkDirectory) == false) { Directory.CreateDirectory(Config.WorkDirectory); } Flickr f = FlickrManager.GetAuthInstance(); f.OnUploadProgress += new EventHandler <FlickrNet.UploadProgressEventArgs>(Flickr_OnUploadProgress); foreach (PhotoLocal photofile in PhotofileList) { //txtResult.AppendText(photofile.Title + " ...\n"); Console.WriteLine(photofile.Title + " ..."); String srcimg = photofile.Path; String dstimg = System.IO.Path.Combine( Config.WorkDirectory, Path.GetFileNameWithoutExtension(srcimg) + ".JPG"); Resize(srcimg, dstimg, resize); PhotoID.Add(f.UploadPicture(dstimg, photofile.Title, Desc, Tags, IsPrivate, false, false)); } if (String.IsNullOrEmpty(Sets) == true) { return; } //txtResult.AppendText(String.Format("Create Sets: {0} ...\n", Sets)); Console.Write(String.Format("Create Sets: {0} ...\n", Sets)); int StartIndex = 0; String PhotosetID; PhotosetID = GetPhotoSetID(Sets); if (PhotosetID == "") { Photoset photoset = f.PhotosetsCreate(Sets, PhotoID[0]); PhotosetID = photoset.PhotosetId; StartIndex++; } if (StartIndex >= PhotoID.Count) { return; } for (int i = StartIndex; i < PhotoID.Count; i++) { f.PhotosetsAddPhoto(PhotosetID, PhotoID[i]); } }