function testAfterUpload_WithPhotos() { $expected = "All done! If you care to make some changes:\n"; $expected .= Phlickr_Uploader::buildEditUrl(array(1, 3, 99)) . "\n"; $this->listener->afterUpload(array(1 => 'photo?', 3 => 'photo?', 99 => 'photo?')); rewind($this->file); $result = stream_get_contents($this->file); $this->assertEquals($expected, $result); }
function testBuildEditUrl() { $result = Phlickr_Uploader::buildEditUrl(array(1, 2, 3)); $this->assertEquals('http://www.flickr.com/tools/uploader_edit.gne?ids=1,2,3', $result); }
/** * @uses Phlickr_Uploader::buildEditUrl() to provide the user with a * URL to edit the uploaded photos. */ public function failedFileUpload($fullPath, Exception $ex) { print $ex; fprintf(STDERR, "ERROR: Could not upload %s...\n", basename($fullPath)); if (count($this->_photos)) { fprintf(STDERR, "Some photos were uploaded:\n%s\n", Phlickr_Uploader::buildEditUrl(array_keys($this->_photos))); } exit(-1); }
function testDelete() { // create a new photo $uploader = new Phlickr_Uploader($this->api); $id = $uploader->Upload(TESTING_FILE_NAME_JPG); sleep(2); // delete it $photo = new Phlickr_AuthedPhoto($this->api, $id); $photo->delete(); try { sleep(2); $photo->refresh(); } catch (Phlickr_Exception $ex) { return; } catch (Exception $ex) { $this->fail('threw the wrong type (' . get_class($ex) . ') of exception.'); } }
// 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);
/** * * @param record_adapter $record * @param array $options * @return string The new distant Id */ public function upload(record_adapter $record, array $options = []) { $uploader = new Phlickr_Uploader($this->_api); $privacy = $this->get_default_privacy(); $uploader->setPerms($privacy['public'], $privacy['friends'], $privacy['family']); $type = $record->get_type() == 'image' ? self::ELEMENT_TYPE_PHOTO : $record->get_type(); switch ($type) { case self::ELEMENT_TYPE_PHOTO: return $uploader->upload($record->get_hd_file()->getRealPath(), $options['title'], $options['description'], $options['tags'], true); break; default: throw new Bridge_Exception_InvalidRecordType('Unknown format'); break; } }