flickr.CollectionsGetTree error (403)

Topics: Developer Forum
Jul 28, 2014 at 11:00 AM
Hi there,

i am supporting website, which has the flickrnet.dll integrated. I don't know exactly since when this error happened, but i read something about ssl changes.

Here is a part of the stacktrace:

[FlickrWebException: HTTP Error 403, Forbidden]
FlickrNet.Flickr.DoGetResponse(Uri url) +604
FlickrNet.Flickr.GetResponse(Dictionary`2 parameters, TimeSpan cacheTimeout) +299
FlickrNet.Flickr.CollectionsGetTree(String collectionId, String userId) +177

Can someone help me?
Coordinator
Jul 28, 2014 at 12:19 PM
Have you updated to the latest version, so you get the full HTTPS support?
Jul 28, 2014 at 12:21 PM
Edited Jul 28, 2014 at 12:25 PM
Oh, I'm sorry, that i did not mention that. Yes, i first updated to v 3.13. Then i wrote in this forum.

Maybe this code sample helps:
protected CollectionCollection getFlickrCollection(String collectionID)
{
    CollectionCollection newCollection = new CollectionCollection();
    newCollection = flickr.CollectionsGetTree(collectionID, userID);
    return newCollection;
}
Coordinator
Jul 30, 2014 at 2:48 PM
I still can't reproduce your error unfortunately.

I've added a unit test to the codebase to try to recreate, but it works fine for me:

https://flickrnet.codeplex.com/SourceControl/latest#FlickrNetTest/CollectionTests.cs

Could you supply the collection id and the user id you are using please?

Sam
Jul 31, 2014 at 7:00 AM
Hello Sam,

thanks for your effort.
My tests at this morning delivered a result, but the executiontime was roundabout 5 minutes. Something has changed, but I don't know what exactly.

I've send the collection id and user id via email.
Coordinator
Jul 31, 2014 at 10:42 AM
I've used the user id and collection id you've sent me and it takes only about a second to call Flickr.

I've only ever seen the 403 error when either you've use the wrong OAuth token, or you are trying to go through a proxy server that uses authentication.

Other than that have you considered trying to use a traffic monitor like Fiddler? A bit hard to set up now that all traffic is HTTPS, but it is still doable.

Sam
Jul 31, 2014 at 10:55 AM
Ok. I'll check this out. But nothing has changed at all. Thanks for your help till now.
Jul 31, 2014 at 1:51 PM
Hi again,

the 403 error is gone since today. But it is not satisfying me, because i don't know why.
Further i have debugged the page, where the flickr webservice is used, a bit und disabled some calls etc.

I think the sum of calls causes this high delay. There are 2 collections, each with 15 albums, each with hundreds of photos, thumbnails etc.
This was a lot of faster in my previous flickrnet.dll version.

Let me point it out:
classicCollection = getFlickrCollection(classicCollectionID);

if (classicCollection.Count > 0)
            {
                /*
                 * get top 15 sets of collection
                 */
                flickrSets = classicCollection.ElementAt(0).Sets;
                List<FlickrGalleryThumb> listClassic = new List<FlickrGalleryThumb>();

                if (flickrSets.Count > 0)
                {
                    for (int i = 0; i < 16; i++)
                    {
                        // save collection set
                        CollectionSet tempSet = flickrSets.ElementAt(i);

                        // save setID and get ID of primary photo
                        string setID = tempSet.SetId.ToString();
                        string primaryID = flickr.PhotosetsGetInfo(setID).PrimaryPhotoId;
                        
                        // create a temporary gallery thumb object
                        tempGalleryThumb = new FlickrGalleryThumb();
                        tempGalleryThumb.GalleryID = setID;
                        tempGalleryThumb.GalleryTitle = tempSet.Title;
                        tempGalleryThumb.GalleryDesc = tempSet.Description;
                        tempGalleryThumb.GalleryCount = (uint)flickr.PhotosetsGetInfo(setID).NumberOfPhotos;

                        // set primary photo as the thumbnail
                        PhotosetPhotoCollection tempPhotoCollection = flickr.PhotosetsGetPhotos(setID);
                        for (int j = 0; j < tempPhotoCollection.Count; j++)
                        {
                            if (tempPhotoCollection.ElementAt(j).PhotoId == primaryID)
                            {
                                tempGalleryThumb.GalleryThumb = tempPhotoCollection.ElementAt(j).SmallUrl;
                                break;
                            }
                        }

                        // the latest gallery
                        if (i == 0)
                        {
                            PanelClassicLatestSetPseudoThumb.BackImageUrl = tempGalleryThumb.GalleryThumb;
                            LinkButtonClassicLatestSet.CommandArgument = tempGalleryThumb.GalleryID;

                            LabelClassicLatestSetHL.Text = tempGalleryThumb.GalleryTitle;
                            LabelClassicLatestSet.Text = LabelClassicLatestSet2.Text = tempGalleryThumb.GalleryDesc;
                        }
                        // add the gallery thumb to the list (for data binding)
                        else
                        {
                            listClassic.Add(tempGalleryThumb);
                        }

                        // Alben-ID übergeben?
                        if (Request.QueryString["gallery"] != null &&
                            Request.QueryString["gallery"] == tempGalleryThumb.GalleryID)
                        {
                            loadClassicGallery = true;
                        }
                    }
                    // data binding
                    ClassicCollection.DataSource = listClassic;
                    ClassicCollection.DataBind();

                    if (loadClassicGallery)
                    {
                        LoadClassicGallery(Request.QueryString["gallery"]);
                        PanelClassicSingleSet.Style["display"] = "block";
                        PanelClassicLatestSet.Style["display"] = "block";
                    }
                }
            }
Coordinator
Jul 31, 2014 at 2:33 PM
Firstly, it would be much better if rather than get all the photos of each photoset just to get the primary photo you just used the existing properties on the photoset class, PrimaryPhotoSmallUrl for example.

Also every time you call flickr.PhotosetsGetInfo(setID) you are going back to Flickr and processing the data every time. You are doing that at least twice for each setID. Do it just once and save the set info and reuse it.

Those two changes would reduce the number of calls to Flickr by 60% and amount of data being processed by about 80-90%.

As an aside, SetID is already a string, so SetID.ToString() is a useless piece of code.
// save collection set
CollectionSet tempSet = flickrSets.ElementAt(i);

// save setID and ID of primary photo
string setID = tempSet.SetId;

// Save this info so we only call it once per set
Photoset setInfo = flickr.PhotosetsGetInfo(setID);
string primaryID = setInfo.PrimaryPhotoId;
                        
// create a temporary gallery thumb object
tempGalleryThumb = new FlickrGalleryThumb();
tempGalleryThumb.GalleryID = setID;
tempGalleryThumb.GalleryTitle = tempSet.Title;
tempGalleryThumb.GalleryDesc = tempSet.Description;
tempGalleryThumb.GalleryCount = (uint)setInfo.NumberOfPhotos;
// Primary Photo Small Url already exists on Photoset class
tempGalleryThumb.GalleryThumb = setInfo.PhotosetSmallUrl;

// no call to flickr.PhotosetsGetPhotos now required.
// the latest gallery
if (i == 0)
{
  ... the rest of your code
Aug 1, 2014 at 9:40 AM
Thanks a lot for your great help.

Sometimes you can't see the forest for the trees.

Have a great time.