function setUp() { $this->api = new Phlickr_Api(TESTING_API_KEY, TESTING_API_SECRET, TESTING_API_TOKEN); $this->api->setEndpointUrl('http://example.com'); // inject the response xml into the cache... // ... first the login details (so it can figure out the user id) $this->api->addResponseToCache('flickr.auth.checkToken', $this->api->getParamsForRequest(), TESTING_RESP_OK_PREFIX . TESTING_XML_CHECKTOKEN . TESTING_RESP_SUFIX); // ... then the full description of the user $this->api->addResponseToCache(Phlickr_AuthedUser::getRequestMethodName(), Phlickr_AuthedUser::getRequestMethodParams(TESTING_XML_USER_ID), TESTING_RESP_OK_PREFIX . TESTING_XML_USER_LONG . TESTING_RESP_SUFIX); $this->user = new Phlickr_AuthedUser($this->api); }
// create a photoset? print 'Create a photoset [y/N] '; if ('y' == substr(trim(fgets(STDIN)), 0, 1)) { $setName = basename($dir); print "Photos will be added to a new photoset named '{$setName}'.\n\n"; } else { $setName = null; print "No photoset will be created.\n\n"; } return $setName; } $api = getApi(); // the idea of this regular expression is that the camera file name // starts with 3 or 4 characters, followed by 4 or 5 digits. if i've // renamed it it would have a space, underscore or hyphen (that we'll // ignore) and then any number of characters before ending with a period // and then 3 character file extension. $pattern = '/\\S{3,4}\\d{4,5}[ _-]?(.*)\\.\\S{3}/'; // the idea of this one is a two digit number, _ or - and then // the name.jpg #$pattern = '/\d{1,2}[ _-]?(.*)\.\S{3}/'; $dir = getDir(); // ... let the user know what we've figured out $user = new Phlickr_AuthedUser($api); $userName = $user->getName(); print "Uploading all the photos in '{$dir}' to {$userName}'s stream\n\n"; $batcher = new CommandlineBatchUploader($dir, $pattern, getSetName($dir)); $uploader = new Phlickr_Uploader($api); $uploader->setTags(getTags()); $uploader->uploadBatch($batcher, new Phlickr_TextUi_UploaderListener()); exit(0);