I've finally made it into the Drupal gliterati! Robert interviewed me earlier this week for the Lullabot podcast. It's all part of my plan to become a Lullabot when I'm done and graduated. Topics included: Phlickr/Flickr, my Summer of Code project, brewing beer and my stumbling speech.
Phlickr ships with a set of unit tests to verify its functionality. The unit tests are divided into two separate suites, offline and online. The unit tests are written using PHPUnit2.
On UNIX systems you'll need to be case sensitive, on Windows everything gets forced to lowercase.
These are some tools I've written with Phlickr:
- FavoriteDesktop downloads a random photo from your favorites list, converts it to a Windows bitmap (using ImageMagick's convert tool) and then sets it as your desktop background image.
- PhlickrUploader is my personal script for uploading a directory full of photos, assigning tags and putting them into photosets.
- GetToken will help you retrieve an authorization token for a given API key/secret.
Make sure that you are running PHP version 5. You can check the version using the following command:
$ php -v
PHP 5.0.4 (cli) (built: Mar 31 2005 02:45:48)
Copyright (c) 1997-2004 The PHP Group
Zend Engine v2.0.4-dev, Copyright (c) 1998-2004 Zend Technologies
Flickr uses a numeric value that they call an authentication token to link the permissions a user grants to an application. You'll need to have an [[API key]] and secret.
To obtain an auth token, you can run the following script on a comand line:
// Prevent from enforcing a time limit on this script
print "This script will help you retrieve a Flickr authorization Token.\n\n";
// Get the user's API key and secret.
print 'API Key: ';
$api_key = trim(fgets(STDIN));
Flickr's API is open to the public for non-commercial usage but they require that each application have a unique API key. They use the key for two things: application usage tracking and authentication. The tracking lets them block broken applications and that sort of thing. The authentication allows a user to grant an application permissions on their account without giving out their password.
This sample demonstrates how to search for photos by tag, sort photos, and create a photoset.
// use the GetToken.php script to generate a config file.
// the cache file isn't required but if you share it's nice.
define('CACHE_FILE', dirname(__FILE__) . '/cache.tmp');
This sample shows how to upload all the JPG files in a directory to Flickr. Take a look at the PhlickrUploader script listed on the tools page for a more complete uploading example.
The following samples should give you an idea how Phlickr works and what you can do with it. There are also some tools written using Phlickr that are useful for both reference and as an idea of how Phlickr can be used in "real world" applications. If you'd like to see other examples please ask.
Most of these examples require that you have an authentication token.
- Q: Does Phlickr work with PHP4?
- A: No, [[Phlickr]] uses several of the new features in PHP5. You'll need to try one of the [[other PHP projects]], most are compatible with PHP4.
- Q: Can you recommend a PHP5 web host
Here are some suggestions to get you started...