Search code examples
c#asp.netflickr

ASP.NET:flickr PhotosSetMeta problems


I have a weird problem. I wrote code with the Flickr API that changes a photo title and description. Now my problem is that the code works only when I debug it (single-stepping).

If i run it without debug it throws Invalid frob (108)

That dosnt make any sense to me.

here is the code:

flicker = new Flickr(key, secret);
            FlickrNet.Cache.CacheDisabled = true;

            string frob = flicker.AuthGetFrob();
            string flickrUrl = flicker.AuthCalcUrl(frob, AuthLevel.Write);

            ProcessStartInfo procInfo =new ProcessStartInfo(flickrUrl);
            Process.Start(procInfo);

            Auth auth = new Auth();
            auth.Permissions = AuthLevel.Write;
            auth = flicker.AuthGetToken(frob);

            flicker.PhotosSetMeta("6959366981", "Title:KODO", "Descreption:SPOPOIDO");

The code connects to flickr, redirects the user to a flickr page that asks the user to accept making changes on their profile, and, if they accept it, it changes one of the photos' title and description.

i think the problem is that in debug mode, the connection stays open, so every thing happens in one call, but in normal mode it executes flickr auth = flicker.AuthGetToken(frob); at the same time the user is trying to do the "accept" on the flickr page.

my question is:

  • can i do authentication programmaticly so i dont have to redirct the page every time?

  • is there a way to keep a connection open while executing code? (im not even sure this is possible)


Solution

  • ok,i got this to work!

    1.you need to check if your app in flicker is a web appliction. 2.you need to make sure you got a callback URL.

    if this both correct you need to create 2 aspx files:

    1: for authentication:

    flicker = new Flickr(key, secret);
            FlickrNet.Cache.CacheDisabled = true;
    
            string flickrUrl = flicker.AuthCalcWebUrl(AuthLevel.Write);
            Response.Redirect(flickrUrl);
            //(the user will be ask to accept making changes on his account once if every thing is working)
    

    2.for sending the (the user will be redirct to this page afther the first part)

    flicker = new Flickr(key, secret);
            FlickrNet.Cache.CacheDisabled = true;
            frob = Request.QueryString["frob"];
    
            Auth auth = flicker.AuthGetToken(frob);
    
            auth.Permissions = AuthLevel.Write;
    
            flicker.PhotosSetMeta("6959366981",TextBox1.Text, TextBox2.Text);
       // PhotosSetMeta(img_id,title,descreption) this function change 1 image (by id) its title and descreption
    

    if you see any errors in the code or mybee a better way to do this please edit it as you will (im pretty new to asp.net).

    if this dosnt work for you check: http://flickrnet.codeplex.com/discussions i got my help there.

    i hope somone will found this usfule :)