Update: The source code of my application can be found on Google Code: Facebook Gallery Import

I have a Gallery where all our family pictures can be seen. My mom, dad and brother all frequently upload pictures on this site, which makes it a central point for all our family’s digital photography sharing & archiving needs.
Encouraged by the fast growth of the Facebook social-networking site, I wanted to be able to easily transfer pictures from my Gallery into Facebook photo albums so that my Facebook friends could see my little guy.

Someone of the Gallery forums had already showed interest in such an application, so I started there and created a new Facebook application that could be used to import pictures.
Not that difficult; just a simple PHP application with forms and a session to gather the user’s Gallery URL, which album and photos he wants to import, and then call the Facebook API (Platform) repeatedly to upload each picture one at a time.

Challenges I faced:

  • Uploading too many pictures at once caused timeouts. Facebook isn’t very patient when waiting for an external application (web page) to complete. I had to upload one picture per page, and repeatedly reload this page until all pictures have been uploaded.
  • Facebook limits photo albums to 60 pictures max. I had to code something that would create a new album each time the current album would be filled with pictures.
  • eAccelerator (0.9.5) has a known bug where try…catch blocks in PHP code are ignored, and Uncaught Exception errors are generated instead. This caused the code that handled expired session to fail until I disabled eAccelerator Optimizer (_php_flag eaccelerator.optimizer 0_ in a .htaccess file).
  • Watermarked pictures that can be found in a Gallery are fetched differently than normal pictures, so I had to modify the helper script to look for watermarked pictures, and use that if any are found.
  • Multisite Gallery installation requires modifications so that the helper script would work correctly.

The result is now a nice Facebook application which seems to work just fine for most people who tried it:
Gallery Import application on Facebook

Now when I want to import Gallery pictures into Facebook, I’m just a few clicks away!