TheMeyers.org Geek

August 20, 2009

Phanfare Badge

Filed under: Phanfare,WordPress — Tags: , , , — admin @ 10:32 am

Sorry, I haven’t yet released the Phanfare-Widget…. I want to rework the code to use a single compound context variable, rather than many single value context variables.  I have started the transition, but I still need to debug and test the new version.  I realized that using the RSS feed interface, is limited compared to what can be accomplished using the Phanfare API interface.

I have been learning the Phanfare API by implementing a clone of Flickr’s Badge javascript code badge_code_v2.gne. This is a PHP module which you install on a server, which mimics the behavior of the Flickr badge function.  In fact you can use the Flickr Badge generator and then replace the Flickr badge call “http://www.flickr.com/badge_code_v2.gne?count=10&display=latest&size=t&layout=x&source=user&user=18867172%40N00" in the generated code, with a call to your Phanfare version, and it will just work!

There are some differences:

  1. For security the username and password for login into Phanfare is stored inside the PHP code.  Rather than being passed in the URL.
  2. You can specify the album_id or year which the random images are pulled from.
  3. I haven’t implemented the display, source,user arguments as it is always choosing from the specified Phanfare user

Example here

I have implemented a PhanfareAPI PHP class to encapsulate all the interaction with their site.  At first I was using SimpleXMLElement but didn’t like the organization of the returned  XML structure.  I wrote XMLParser which uses the PHP internal xml_parser_create, with startElement, endElement callbacks.  This returns a pure PHP nested array structure, which is much easier to handle when iterating over repeating structures with foreach.  The performance is slightly faster than SimpleXMLElement, and there is little (if any) special case code needed when walking the returned XML structures.

I am working on a Caching class to improve the performance using a sqlite DB.  The performance is excellent, but the programmer interface is not yet smooth.  The assumption is that the photo site meta information doesn’t change that often, and so can be cached for a longer period of time.

Example: The same badge test, using Caching here

No Comments

No comments yet.

RSS feed for comments on this post. TrackBack URL

Sorry, the comment form is closed at this time.

Powered by WordPress

Bad Behavior has blocked 19 access attempts in the last 7 days.