Upload photo in flickr by asp.net code
January 8, 2013 4 Comments
In my applications are providing to facility to share their customer’s images but for that key issue is where those images need to store because generally every host environment have very limited access to update photos.
Flickr is providing a facility to upload any number of images and providing a link so we can share this link in any where.
Below are the steps for that.
Need to create a app in flicker and generate app key from below link
Once you will create app that will returns you below key
Api secrete key
- Then you can use that key in below code
Flickr flickr = new Flickr(ConfigurationManager.AppSettings["apiKey"], ConfigurationManager.AppSettings["shardSecret"]); flickr.OAuthAccessTokenSecret = "b149b2e96eb8072a"; flickr.OAuthAccessToken = "72157631518163710-91816d732ba5f46c"; string FileuploadedID = flickr.UploadPicture(@"E:\Documents\TweetingRoom\Logo\Main-screen.jpg", "TwittingRoom", "TwittingRoom Image", "ClientName", true, false, false); PhotoInfo oPhotoInfo = flickr.PhotosGetInfo(FileuploadedID); string FileULR = oPhotoInfo.LargeUrl; Response.Write(FileULR);
In this code I have stored api key and api secrete key in web.config file.
Also for upload file user first need to get access token key and access token secrete key so for that you need to
Flickr f = new Flickr(ConfigurationManager.AppSettings["apiKey"], ConfigurationManager.AppSettings["shardSecret"]); OAuthRequestToken requestToken = f.OAuthGetRequestToken("oob"); string url = f.OAuthCalculateAuthorizationUrl(requestToken.Token, AuthLevel.Write);
So it will show on request token and use that token in below code:
OAuthRequestToken requestToken = f.OAuthGetRequestToken("oob"); var accessToken = f.OAuthGetAccessToken(requestToken, VerifierTextBox.Text);
In accessToken this object user can get access token and access token secrete key.
So now you can use this access token and token screate key to upload file on above provided code and that will returns you url, thumbnail url and flickr page as to show image.