The next version of the source code for the Flickr.Net API Library has been released.
[Download Latest Source](/flickr/flickr-api).
See the above page for changelog – there are some good ones in there.
There are also two new ‘examples’ pages.
* [Examples – Part 1](/flickr/flickr-api/examples-part-1)
* [Examples – Part 2](/flickr/flickr-api/examples-part-2)
Feel free to add comments as you want.
I’ve noticed a slight problem. The setter for Page in PhotoSearchOptions.cs throws an exception if it’s zero, however if you call one of the Flickr.PhotosSearch methods that doesn’t accept the page it defaults to zero, passes that down to the method that populates the PhotoSearchOptions object and an exception will be thrown. Hope that makes sense!
When I use your code locally for testing, I it works fine, but when I load it to my website, I get an error. Below. It appears that I’m missing something. Any thoughts on what might be the cause and how I can fix this?
System.DllNotFoundException: Unable to load DLL ‘rasapi32.dll’: A dynamic link library (DLL) initialization routine failed. (Exception from HRESULT: 0x8007045A)
at System.Net.UnsafeNclNativeMethods.RasHelper.RasEnumConnections(RASCONN[] lprasconn, UInt32& lpcb, UInt32& lpcConnections)
at System.Net.UnsafeNclNativeMethods.RasHelper.GetCurrentConnectoid()
at System.Net.AutoWebProxyScriptEngine.AutoDetector.Initialize()
at System.Net.AutoWebProxyScriptEngine.AutoDetector.get_CurrentAutoDetector()
at System.Net.AutoWebProxyScriptEngine..ctor(WebProxy proxy, Boolean useRegistry)
at System.Net.WebProxy.UnsafeUpdateFromRegistry()
at System.Net.WebProxy..ctor(Boolean enableAutoproxy)
at System.Net.WebProxy.GetDefaultProxy()
at FlickrNet.Flickr..ctor(String apiKey, String sharedSecret, String token) in e:webaldaroncom0htdocsservicesApp_CodeFlickrNetFlickr.cs:line 42
at FlickrNet.Flickr..ctor(String apiKey) in e:webaldaroncom0htdocsservicesApp_CodeFlickrNetFlickr.cs:line 136
at Aldaron.Services.Photo.HelloWorld() in e:webaldaroncom0htdocsservicesApp_CodePhoto.asmx.cs:line 59
Thanks so much for this library. I added this to the groups section. It seems to work just fine
///
/// Returns a that match the text specified.
///
/// text used to search for groups
/// A instance.
public PoolGroups GroupsSearch(string text)
{
return GroupsSearch(text, 0, 0);
}
///
/// Returns a that match the text specified.
///
///
/// Number of groups to include per page.
/// The page to download this time.
/// A instance.
public PoolGroups GroupsSearch(string text, int perPage, int page)
{
NameValueCollection parameters = new NameValueCollection();
parameters.Add(“method”, “flickr.groups.search”);
parameters.Add(“text”, text);
if( perPage > 0 ) parameters.Add(“per_page”, perPage.ToString());
if( page > 0) parameters.Add(“page”, page.ToString());
FlickrNet.Response response = GetResponseCache(parameters);
if( response.Status == ResponseStatus.OK )
{
return response.PoolGroups;
}
else
{
throw new FlickrException(response.Error);
}
}
Also added this
///
/// Gets a users public photos. Excludes private photos.
///
/// The user id of the user.
/// The collection of photos contained within a object.
public Photos PeopleGetPublicPhotos(string userId)
{
return PeopleGetPublicPhotos(userId, 0, 0);
}
public Photos PeopleGetPublicPhotos(string userId, int perPage, int page)
{
NameValueCollection parameters = new NameValueCollection();
parameters.Add(“method”, “flickr.people.getPublicPhotos”);
parameters.Add(“api_key”, _apiKey);
parameters.Add(“user_id”, userId);
if( perPage > 0 ) parameters.Add(“per_page”, perPage.ToString());
if( page > 0) parameters.Add(“page”, page.ToString());
FlickrNet.Response response = GetResponseCache(parameters);
if( response.Status == ResponseStatus.OK )
{
return response.Photos;
}
else
{
throw new FlickrException(response.Error);
}
}
Aldaron:
Disclaimer: I haven’t even looked at any of this code yet.
But looking at your stack trace, I’d say it’s calling unmanaged code from RASAPI32.dll.
A couple of things could be going here, but it’s more than likely not allowed to make this call from the
It may not like the unmanaged call from the
your
to try to figure out the internet connection proxy settings automatically.
Hi, I’m getting an error trying to access the PhotoCollection part of Photos
photos.PhotoCollection.Item(100) throws an exception, despite the collection having 134 photo objects in it.. (According to photos.TotalPhotos)
System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
Parameter name: Index was out of range. Must be non-negative and less than the size of the collection.
at System.Collections.CollectionBase.System.Collections.IList.get_Item(Int32 index)
at FlickrNet.PhotoCollection.get_Item(Int32 index)
at FlickrPod.FlickrPod.btnSync_Click(Object sender, EventArgs e) in J:DataVisual Studio ProjectsFlickrPodFlickrPod.vb:line 211
The TotalPhotos is not the number of photos returned by the function – it is the total number of photos which CAN be returned – they are split into pages (defaults to 100 funnily enough) – you’ve only returned the first page.
That makes sense, thanks.
Hi,
Lately i have problem getting photos info (PhotosGetInfo).
here is the stack trace of the exception:
> Invalid response received (There is an error in XML document (14, 9).)
> (9998) at FlickrNet.Flickr.DoGetResponse(String url)
> at FlickrNet.Flickr.GetResponse(NameValueCollection parameters,
> TimeSpan cacheTimeout)
> at FlickrNet.Flickr.GetResponseCache(NameValueCollection
> parameters)
> at FlickrNet.Flickr.PhotosGetInfo(String photoId, String secret)
> at FlickrNet.Flickr.PhotosGetInfo(String photoId)
>
will appreciate your response.
rnv
I found the reason for the problem i wrote in my previous comment.
The tagid is being parsed as ‘long’ in PhotoInfo.cs line 264. it should be ‘string’. maybe it was long and have been changed to string recently in resonpose string.
I’m seeing a different problem: Flickr is returning tag IDs that have embedded dashes, like this:
id=”413194-87434047-1700″
This is not consistent with what Cal has said about all object identifiers being 64-bit integers. I’m hoping this is just a glitch that creeped into the API code that will get patched (I’ve raised this question on the developer list).
Yeah, got the TagId problem fixed – we’re about a week away from a new release, with lots of bug fixes and new functionality.
New version of API has now been released. See http://www.wackylabs.net/flickr/flickr-api/ for more details.