├── examples
├── Agateware_Example.JPG
├── config.dist.php
├── unauthenticated_requests.php
├── caching.php
├── uploads.php
├── recent_photos.php
└── get_auth_token.php
├── src
├── FlickrException.php
├── ApiMethodGroup.php
├── CommonsApi.php
├── PhotosUploadApi.php
├── ProfileApi.php
├── PhotosTransformApi.php
├── ReflectionApi.php
├── CamerasApi.php
├── TestApi.php
├── CollectionsApi.php
├── PhotosLicensesApi.php
├── GroupsMembersApi.php
├── InterestingnessApi.php
├── ActivityApi.php
├── BlogsApi.php
├── PhotosetsCommentsApi.php
├── GroupsDiscussTopicsApi.php
├── PhotosNotesApi.php
├── Oauth
│ └── PhpFlickrService.php
├── PandaApi.php
├── PrefsApi.php
├── Util.php
├── PhotosSuggestionsApi.php
├── PhotosPeopleApi.php
├── ContactsApi.php
├── GroupsDiscussRepliesApi.php
├── PhotosCommentsApi.php
├── GroupsPoolsApi.php
├── MachinetagsApi.php
├── GroupsApi.php
├── UrlsApi.php
├── TagsApi.php
├── Uploader.php
├── FavoritesApi.php
├── PushApi.php
├── TestimonialsApi.php
├── PhotosGeoApi.php
├── PeopleApi.php
└── PhotosetsApi.php
├── .github
├── dependabot.yml
└── workflows
│ └── ci.yml
├── .gitignore
├── .phan
├── config.php
└── baseline.php
├── phpunit.xml.dist
├── tests
├── UtilTest.php
├── ApiMethodGroup
│ ├── TestApiTest.php
│ ├── PhotosetsApiTest.php
│ ├── UrlsApiTest.php
│ └── PhotosApiTest.php
└── TestCase.php
├── phpcs.xml
├── composer.json
├── bin
└── reflect.php
└── README.md
/examples/Agateware_Example.JPG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/samwilson/phpflickr/HEAD/examples/Agateware_Example.JPG
--------------------------------------------------------------------------------
/src/FlickrException.php:
--------------------------------------------------------------------------------
1 | [
5 | 'src',
6 | 'vendor',
7 | ],
8 | 'exclude_file_regex' => '@^vendor/.*/(tests?|Tests?)/@',
9 | 'exclude_analysis_directory_list' => [
10 | 'vendor/'
11 | ],
12 | ];
13 |
--------------------------------------------------------------------------------
/src/ApiMethodGroup.php:
--------------------------------------------------------------------------------
1 | flickr = $flickr;
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/phpunit.xml.dist:
--------------------------------------------------------------------------------
1 |
license, date_upload, date_taken,
19 | * owner_name, icon_server, original_format,
20 | * last_update, geo, tags,
21 | * machine_tags, o_dims, views,
22 | * media, path_alias, url_sq,
23 | * url_t, url_s, url_q, url_m,
24 | * url_n, url_z, url_c, url_l,
25 | * url_o
26 | * @param string $perPage Number of photos to return per page. If this argument is
27 | * omitted, it defaults to 100. The maximum allowed value is 500.
28 | * @param string $page The page of results to return. If this argument is omitted,
29 | * it defaults to 1.
30 | * @return
31 | */
32 | public function getList($date = null, $extras = null, $perPage = null, $page = null)
33 | {
34 | $params = [
35 | 'date' => $date,
36 | 'extras' => $extras,
37 | 'per_page' => $perPage,
38 | 'page' => $page
39 | ];
40 | return $this->flickr->request('flickr.interestingness.getList', $params);
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/examples/recent_photos.php:
--------------------------------------------------------------------------------
1 | setAccessToken($accessToken);
28 | $token->setAccessTokenSecret($accessTokenSecret);
29 | $storage = new \OAuth\Common\Storage\Memory();
30 | $storage->storeAccessToken('Flickr', $token);
31 |
32 | // Create PhpFlickr.
33 | $phpFlickr = new \Samwilson\PhpFlickr\PhpFlickr($apiKey, $apiSecret);
34 |
35 | // Give PhpFlickr the storage containing the access token.
36 | $phpFlickr->setOauthStorage($storage);
37 |
38 | // Make a request.
39 | $recent = $phpFlickr->photos()->getRecent([], 10);
40 |
41 | // Display a list of photo titles.
42 | echo ''2d') or hours ('4h'). The
38 | * default behavoir is to return changes since the beginning of the previous user
39 | * session.
40 | * @param string $perPage Number of items to return per page. If this argument is
41 | * omitted, it defaults to 10. The maximum allowed value is 50.
42 | * @param string $page The page of results to return. If this argument is omitted,
43 | * it defaults to 1.
44 | * @return array
45 | */
46 | public function userPhotos($timeframe = null, $perPage = null, $page = null)
47 | {
48 | $params = [
49 | 'timeframe' => $timeframe,
50 | 'per_page' => $perPage,
51 | 'page' => $page
52 | ];
53 | return $this->flickr->request('flickr.activity.userPhotos', $params);
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/examples/get_auth_token.php:
--------------------------------------------------------------------------------
1 | setOauthStorage($storage);
29 |
30 | if (!isset($_GET['oauth_token'])) {
31 | $callbackHere = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
32 | $url = $flickr->getAuthUrl('delete', $callbackHere);
33 | echo "$url";
34 | }
35 |
36 | if (isset($_GET['oauth_token'])) {
37 | $accessToken = $flickr->retrieveAccessToken($_GET['oauth_verifier'], $_GET['oauth_token']);
38 | }
39 | } else {
40 | /*
41 | * The CLI workflow.
42 | */
43 | $storage = new \OAuth\Common\Storage\Memory();
44 | $flickr->setOauthStorage($storage);
45 |
46 | $url = $flickr->getAuthUrl('delete');
47 | echo "Go to $url\nEnter access code: ";
48 | $code = fgets(STDIN);
49 | $verifier = preg_replace('/[^0-9]/', '', $code);
50 | $accessToken = $flickr->retrieveAccessToken($verifier);
51 | }
52 |
53 | if (isset($accessToken) && $accessToken instanceof \OAuth\Common\Token\TokenInterface) {
54 | /*
55 | * You should save the access token and its secret somewhere safe.
56 | */
57 | echo '$accessToken = "' . $accessToken->getAccessToken() . '";' . PHP_EOL;
58 | echo '$accessTokenSecret = "' . $accessToken->getAccessTokenSecret() . '";' . PHP_EOL;
59 |
60 | /*
61 | * Any methods can now be called.
62 | */
63 | $login = $flickr->test()->login();
64 | echo "You are authenticated as: {$login['username']}\n";
65 | }
66 |
--------------------------------------------------------------------------------
/src/BlogsApi.php:
--------------------------------------------------------------------------------
1 | flickr.blogs.getServices().
16 | * @return array
17 | */
18 | public function getList($service = null)
19 | {
20 | $params = [
21 | 'service' => $service
22 | ];
23 | return $this->flickr->request('flickr.blogs.getList', $params);
24 | }
25 |
26 | /**
27 | * Return a list of Flickr supported blogging services
28 | *
29 | * This method does not require authentication.
30 | *
31 | * @link https://www.flickr.com/services/api/flickr.blogs.getServices.html
32 | *
33 | * @return array
34 | */
35 | public function getServices()
36 | {
37 | return $this->flickr->request('flickr.blogs.getServices');
38 | }
39 |
40 | /**
41 | * This method requires authentication.
42 | *
43 | * @link https://www.flickr.com/services/api/flickr.blogs.postPhoto.html
44 | * @param string $photoId The id of the photo to blog
45 | * @param string $title The blog post title
46 | * @param string $description The blog post body
47 | * @param string $blogPassword The password for the blog (used when the blog does
48 | * not have a stored password).
49 | * @param string $service A Flickr supported blogging service. Instead of passing
50 | * a blog id you can pass a service id and we'll post to the first blog of that
51 | * service we find.
52 | * @param string $blogId The id of the blog to post to.
53 | * @return array
54 | */
55 | public function postPhoto($photoId, $title, $description, $blogPassword = null, $service = null, $blogId = null)
56 | {
57 | $params = [
58 | 'blog_id' => $blogId,
59 | 'photo_id' => $photoId,
60 | 'title' => $title,
61 | 'description' => $description,
62 | 'blog_password' => $blogPassword,
63 | 'service' => $service
64 | ];
65 | return $this->flickr->request('flickr.blogs.postPhoto', $params);
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/src/PhotosetsCommentsApi.php:
--------------------------------------------------------------------------------
1 | $photosetId,
21 | 'comment_text' => $commentText
22 | ];
23 | return $this->flickr->request('flickr.photosets.comments.addComment', $params);
24 | }
25 |
26 | /**
27 | * Delete a photoset comment as the currently authenticated user.
28 | *
29 | * This method requires authentication.
30 | *
31 | * @link https://www.flickr.com/services/api/flickr.photosets.comments.deleteComment.html
32 | * @param string $commentId The id of the comment to delete from a photoset.
33 | * @return
34 | */
35 | public function deleteComment($commentId)
36 | {
37 | $params = [
38 | 'comment_id' => $commentId
39 | ];
40 | return $this->flickr->request('flickr.photosets.comments.deleteComment', $params);
41 | }
42 |
43 | /**
44 | * Edit the text of a comment as the currently authenticated user.
45 | *
46 | * This method requires authentication.
47 | *
48 | * @link https://www.flickr.com/services/api/flickr.photosets.comments.editComment.html
49 | * @param string $commentId The id of the comment to edit.
50 | * @param string $commentText Update the comment to this text.
51 | * @return
52 | */
53 | public function editComment($commentId, $commentText)
54 | {
55 | $params = [
56 | 'comment_id' => $commentId,
57 | 'comment_text' => $commentText
58 | ];
59 | return $this->flickr->request('flickr.photosets.comments.editComment', $params);
60 | }
61 |
62 | /**
63 | * Returns the comments for a photoset.
64 | *
65 | * This method does not require authentication.
66 | *
67 | * @link https://www.flickr.com/services/api/flickr.photosets.comments.getList.html
68 | * @param string $photosetId The id of the photoset to fetch comments for.
69 | * @return
70 | */
71 | public function getList($photosetId)
72 | {
73 | $params = [
74 | 'photoset_id' => $photosetId
75 | ];
76 | return $this->flickr->request('flickr.photosets.comments.getList', $params);
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/src/GroupsDiscussTopicsApi.php:
--------------------------------------------------------------------------------
1 | $groupId,
22 | 'subject' => $subject,
23 | 'message' => $message
24 | ];
25 | return $this->flickr->request('flickr.groups.discuss.topics.add', $params);
26 | }
27 |
28 | /**
29 | * Get information about a group discussion topic.
30 | *
31 | * This method does not require authentication.
32 | *
33 | * @link https://www.flickr.com/services/api/flickr.groups.discuss.topics.getInfo.html
34 | * @param string $groupId NSID or group alias of the group to which the topic
35 | * belongs. Making this parameter optional for legacy reasons, but it is highly
36 | * recommended to pass this in to get better performance.
37 | * @param string $topicId The ID for the topic to edit.
38 | * @return
39 | */
40 | public function getInfo($groupId, $topicId)
41 | {
42 | $params = [
43 | 'group_id' => $groupId,
44 | 'topic_id' => $topicId
45 | ];
46 | return $this->flickr->request('flickr.groups.discuss.topics.getInfo', $params);
47 | }
48 |
49 | /**
50 | * Get a list of discussion topics in a group.
51 | *
52 | * This method does not require authentication.
53 | *
54 | * @link https://www.flickr.com/services/api/flickr.groups.discuss.topics.getList.html
55 | * @param string $groupId The NSID or path alias of the group to fetch information
56 | * for.
57 | * @param string $perPage Number of photos to return per page. If this argument is
58 | * omitted, it defaults to 100. The maximum allowed value is 500.
59 | * @param string $page The page of results to return. If this argument is omitted,
60 | * it defaults to 1.
61 | * @return
62 | */
63 | public function getList($groupId, $perPage = null, $page = null)
64 | {
65 | $params = [
66 | 'group_id' => $groupId,
67 | 'per_page' => $perPage,
68 | 'page' => $page
69 | ];
70 | return $this->flickr->request('flickr.groups.discuss.topics.getList', $params);
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/src/PhotosNotesApi.php:
--------------------------------------------------------------------------------
1 | $photoId,
26 | 'note_x' => $noteX,
27 | 'note_y' => $noteY,
28 | 'note_w' => $noteW,
29 | 'note_h' => $noteH,
30 | 'note_text' => $noteText
31 | ];
32 | return $this->flickr->request('flickr.photos.notes.add', $params);
33 | }
34 |
35 | /**
36 | * Delete a note from a photo.
37 | *
38 | * This method requires authentication.
39 | *
40 | * @link https://www.flickr.com/services/api/flickr.photos.notes.delete.html
41 | * @param string $noteId The id of the note to delete
42 | * @return
43 | */
44 | public function delete($noteId)
45 | {
46 | $params = [
47 | 'note_id' => $noteId
48 | ];
49 | return $this->flickr->request('flickr.photos.notes.delete', $params);
50 | }
51 |
52 | /**
53 | * Edit a note on a photo. Coordinates and sizes are in pixels, based on the 500px
54 | * image size shown on individual photo pages.
55 |
56 | *
57 | * This method requires authentication.
58 | *
59 | * @link https://www.flickr.com/services/api/flickr.photos.notes.edit.html
60 | * @param string $noteId The id of the note to edit
61 | * @param string $noteX The left coordinate of the note
62 | * @param string $noteY The top coordinate of the note
63 | * @param string $noteW The width of the note
64 | * @param string $noteH The height of the note
65 | * @param string $noteText The description of the note
66 | * @return
67 | */
68 | public function edit($noteId, $noteX, $noteY, $noteW, $noteH, $noteText)
69 | {
70 | $params = [
71 | 'note_id' => $noteId,
72 | 'note_x' => $noteX,
73 | 'note_y' => $noteY,
74 | 'note_w' => $noteW,
75 | 'note_h' => $noteH,
76 | 'note_text' => $noteText
77 | ];
78 | return $this->flickr->request('flickr.photos.notes.edit', $params);
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/tests/TestCase.php:
--------------------------------------------------------------------------------
1 | flickrs[$authed])) {
25 | return $this->flickrs[$authed];
26 | }
27 |
28 | // Get config values from env vars or the tests/config.php file.
29 | $apiKey = getenv('FLICKR_API_KEY');
30 | $apiSecret = getenv('FLICKR_API_SECRET');
31 | $accessToken = getenv('FLICKR_ACCESS_TOKEN');
32 | $accessTokenSecret = getenv('FLICKR_ACCESS_SECRET');
33 | $configFile = __DIR__ . '/config.php';
34 | if (empty($apiKey) && file_exists($configFile)) {
35 | require $configFile;
36 | }
37 | if (empty($apiKey)) {
38 | // Skip if no key found, so PRs from forks can still be run in CI.
39 | static::markTestSkipped('No Flickr API key set (in either the FLICKR_* env vars or ' . $configFile . ')');
40 | }
41 | try {
42 | $this->flickrs[$authed] = new PhpFlickr($apiKey, $apiSecret);
43 | } catch (FlickrException $ex) {
44 | static::markTestSkipped($ex->getMessage());
45 | }
46 |
47 | // Authenticate?
48 | if ($authenticate && !empty($accessToken) && !empty($accessTokenSecret)) {
49 | $token = new StdOAuth1Token();
50 | $token->setAccessToken($accessToken);
51 | $token->setAccessTokenSecret($accessTokenSecret);
52 | $this->flickrs[$authed]->getOauthTokenStorage()->storeAccessToken('Flickr', $token);
53 | try {
54 | $authenticated = $this->flickrs[$authed]->test()->login();
55 | } catch (FlickrException $e) {
56 | $authenticated = false;
57 | }
58 | if (!$authenticated) {
59 | static::markTestSkipped('Unable to authenticate with provided access token.');
60 | }
61 | }
62 | if ($authenticate && empty($accessToken)) {
63 | static::markTestSkipped(
64 | 'Access token required for this test. '
65 | . 'Please use examples/get_auth_token.php to get token to add to tests/config.php.'
66 | );
67 | }
68 |
69 | return $this->flickrs[$authed];
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/.phan/baseline.php:
--------------------------------------------------------------------------------
1 | [
5 | 'src/CamerasApi.php' => ['PhanUnextractableAnnotation'],
6 | 'src/CollectionsApi.php' => ['PhanUnextractableAnnotation'],
7 | 'src/CommonsApi.php' => ['PhanUnextractableAnnotation'],
8 | 'src/ContactsApi.php' => ['PhanUnextractableAnnotation'],
9 | 'src/FavoritesApi.php' => ['PhanUnextractableAnnotation'],
10 | 'src/GalleriesApi.php' => ['PhanTypeMismatchDefault', 'PhanUnextractableAnnotation'],
11 | 'src/GroupsApi.php' => ['PhanUnextractableAnnotation'],
12 | 'src/GroupsDiscussRepliesApi.php' => ['PhanUnextractableAnnotation'],
13 | 'src/GroupsDiscussTopicsApi.php' => ['PhanUnextractableAnnotation'],
14 | 'src/GroupsMembersApi.php' => ['PhanUnextractableAnnotation'],
15 | 'src/GroupsPoolsApi.php' => ['PhanUnextractableAnnotation'],
16 | 'src/InterestingnessApi.php' => ['PhanUnextractableAnnotation'],
17 | 'src/MachinetagsApi.php' => ['PhanUnextractableAnnotation'],
18 | 'src/PandaApi.php' => ['PhanUnextractableAnnotation'],
19 | 'src/PeopleApi.php' => ['PhanUnextractableAnnotation'],
20 | 'src/PhotosApi.php' => ['PhanTypeMismatchDefault', 'PhanTypeMismatchForeach', 'PhanUnextractableAnnotation'],
21 | 'src/PhotosCommentsApi.php' => ['PhanUnextractableAnnotation'],
22 | 'src/PhotosGeoApi.php' => ['PhanUnextractableAnnotation'],
23 | 'src/PhotosNotesApi.php' => ['PhanUnextractableAnnotation'],
24 | 'src/PhotosPeopleApi.php' => ['PhanUnextractableAnnotation'],
25 | 'src/PhotosSuggestionsApi.php' => ['PhanUnextractableAnnotation'],
26 | 'src/PhotosTransformApi.php' => ['PhanUnextractableAnnotation'],
27 | 'src/PhotosUploadApi.php' => ['PhanUnextractableAnnotation'],
28 | 'src/PhotosetsCommentsApi.php' => ['PhanUnextractableAnnotation'],
29 | 'src/PhpFlickr.php' => [
30 | 'PhanInvalidCommentForDeclarationType', 'PhanTypeConversionFromArray', 'PhanTypeMismatchArgumentInternal',
31 | 'PhanTypeMismatchProperty', 'PhanTypeMismatchReturnProbablyReal', 'PhanUndeclaredClassInstanceof',
32 | 'PhanUndeclaredClassMethod', 'PhanUndeclaredMethod', 'PhanUndeclaredTypeParameter',
33 | 'PhanUndeclaredTypeProperty', 'PhanUndeclaredTypeReturnType', 'PhanUnreferencedUseNormal'
34 | ],
35 | 'src/PlacesApi.php' => ['PhanUnextractableAnnotation'],
36 | 'src/PrefsApi.php' => ['PhanUnextractableAnnotation'],
37 | 'src/PushApi.php' => ['PhanUnextractableAnnotation'],
38 | 'src/ReflectionApi.php' => ['PhanUnextractableAnnotation'],
39 | 'src/StatsApi.php' => ['PhanUnextractableAnnotation'],
40 | 'src/TagsApi.php' => ['PhanUnextractableAnnotation'],
41 | 'src/TestApi.php' => ['PhanUndeclaredClassCatch'],
42 | 'src/TestimonialsApi.php' => ['PhanUnextractableAnnotation'],
43 | 'src/Uploader.php' => [
44 | 'PhanUndeclaredClassMethod', 'PhanUndeclaredProperty',
45 | 'PhanUndeclaredTypeThrowsType', 'PhanUnreferencedUseNormal'
46 | ],
47 | 'src/Util.php' => ['PhanParamSuspiciousOrder'],
48 | ],
49 | ];
50 |
--------------------------------------------------------------------------------
/src/Oauth/PhpFlickrService.php:
--------------------------------------------------------------------------------
1 | storage->retrieveAccessToken($this->service());
75 | assert($token instanceof TokenInterface);
76 | $this->signature->setTokenSecret($token->getAccessTokenSecret());
77 | $authParameters = $this->getBasicAuthorizationHeaderInfo();
78 | if (isset($authParameters['oauth_callback'])) {
79 | unset($authParameters['oauth_callback']);
80 | }
81 | $authParameters = array_merge($authParameters, ['oauth_token' => $token->getAccessToken()]);
82 | $signatureParams = array_merge($authParameters, $args);
83 | $authParameters['oauth_signature'] = $this->signature->getSignature(
84 | new Uri($uri),
85 | $signatureParams
86 | );
87 | return array_merge($authParameters, $args);
88 | }
89 | }
90 |
--------------------------------------------------------------------------------
/src/PandaApi.php:
--------------------------------------------------------------------------------
1 | Flickr
9 | * pandas, from whom you can request photos using the flickr.panda.getPhotos API
11 | * method.
12 | description,
52 | * license, date_upload, date_taken,
53 | * owner_name, icon_server, original_format,
54 | * last_update, geo, tags,
55 | * machine_tags, o_dims, views,
56 | * media, path_alias, url_sq,
57 | * url_t, url_s, url_q, url_m,
58 | * url_n, url_z, url_c, url_l,
59 | * url_o
60 | * @param string $perPage Number of photos to return per page. If this argument is
61 | * omitted, it defaults to 100. The maximum allowed value is 500.
62 | * @param string $page The page of results to return. If this argument is omitted,
63 | * it defaults to 1.
64 | * @return
65 | */
66 | public function getPhotos($pandaName, $extras = null, $perPage = null, $page = null)
67 | {
68 | $params = [
69 | 'panda_name' => $pandaName,
70 | 'extras' => $extras,
71 | 'per_page' => $perPage,
72 | 'page' => $page
73 | ];
74 | return $this->flickr->request('flickr.panda.getPhotos', $params);
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/src/PrefsApi.php:
--------------------------------------------------------------------------------
1 | flickr->request('flickr.prefs.getContentType');
19 | }
20 |
21 | /**
22 | * Returns the default privacy level for geographic information attached to the
23 | * user's photos and whether or not the user has chosen to use geo-related EXIF
24 | * information to automatically geotag their photos.
25 |
26 | Possible values, for viewing
27 | * geotagged photos, are:
28 |
29 | friendsfamilybothneitherdescription,
99 | * license, date_upload, date_taken,
100 | * owner_name, icon_server, original_format,
101 | * last_update, geo, tags,
102 | * machine_tags, o_dims, views,
103 | * media, path_alias, url_sq,
104 | * url_t, url_s, url_q, url_m,
105 | * url_n, url_z, url_c, url_l,
106 | * url_o
107 | * @param string $perPage Number of photos to return per page. If this argument is
108 | * omitted, it defaults to 100. The maximum allowed value is 500.
109 | * @param string $page The page of results to return. If this argument is omitted,
110 | * it defaults to 1.
111 | * @return
112 | */
113 | public function getRecentForContacts(
114 | $dateLastcomment = null,
115 | $contactsFilter = null,
116 | $extras = null,
117 | $perPage = null,
118 | $page = null
119 | ) {
120 | $params = [
121 | 'date_lastcomment' => $dateLastcomment,
122 | 'contacts_filter' => $contactsFilter,
123 | 'extras' => $extras,
124 | 'per_page' => $perPage,
125 | 'page' => $page
126 | ];
127 | return $this->flickr->request('flickr.photos.comments.getRecentForContacts', $params);
128 | }
129 | }
130 |
--------------------------------------------------------------------------------
/src/GroupsPoolsApi.php:
--------------------------------------------------------------------------------
1 | $photoId,
23 | 'group_id' => $groupId
24 | ];
25 | return $this->flickr->request('flickr.groups.pools.add', $params);
26 | }
27 |
28 | /**
29 | * Returns next and previous photos for a photo in a group pool.
30 | *
31 | * This method does not require authentication.
32 | *
33 | * @link https://www.flickr.com/services/api/flickr.groups.pools.getContext.html
34 | * @param string $photoId The id of the photo to fetch the context for.
35 | * @param string $groupId The nsid of the group who's pool to fetch the photo's
36 | * context for.
37 | * @return
38 | */
39 | public function getContext($photoId, $groupId)
40 | {
41 | $params = [
42 | 'photo_id' => $photoId,
43 | 'group_id' => $groupId
44 | ];
45 | return $this->flickr->request('flickr.groups.pools.getContext', $params);
46 | }
47 |
48 | /**
49 | * Returns a list of groups to which you can add photos.
50 | *
51 | * This method requires authentication.
52 | *
53 | * @link https://www.flickr.com/services/api/flickr.groups.pools.getGroups.html
54 | * @param string $page The page of results to return. If this argument is omitted,
55 | * it defaults to 1.
56 | * @param string $perPage Number of groups to return per page. If this argument is
57 | * omitted, it defaults to 400. The maximum allowed value is 400.
58 | * @return
59 | */
60 | public function getGroups($page = null, $perPage = null)
61 | {
62 | $params = [
63 | 'page' => $page,
64 | 'per_page' => $perPage
65 | ];
66 | return $this->flickr->request('flickr.groups.pools.getGroups', $params);
67 | }
68 |
69 | /**
70 | * Returns a list of pool photos for a given group, based on the permissions of the
71 | * group and the user logged in (if any).
72 | *
73 | * This method does not require authentication.
74 | *
75 | * @link https://www.flickr.com/services/api/flickr.groups.pools.getPhotos.html
76 | * @param string $groupId The id of the group who's pool you which to get the photo
77 | * list for.
78 | * @param string $tags A tag to filter the pool with. At the moment only one tag at
79 | * a time is supported.
80 | * @param string $userId The nsid of a user. Specifiying this parameter will
81 | * retrieve for you only those photos that the user has contributed to the group
82 | * pool.
83 | * @param string $extras A comma-delimited list of extra information to fetch for
84 | * each returned record. Currently supported fields are: description,
85 | * license, date_upload, date_taken,
86 | * owner_name, icon_server, original_format,
87 | * last_update, geo, tags,
88 | * machine_tags, o_dims, views,
89 | * media, path_alias, url_sq,
90 | * url_t, url_s, url_q, url_m,
91 | * url_n, url_z, url_c, url_l,
92 | * url_o
93 | * @param string $perPage Number of photos to return per page. If this argument is
94 | * omitted, it defaults to 100. The maximum allowed value is 500.
95 | * @param string $page The page of results to return. If this argument is omitted,
96 | * it defaults to 1.
97 | * @return
98 | */
99 | public function getPhotos($groupId, $tags = null, $userId = null, $extras = null, $perPage = null, $page = null)
100 | {
101 | $params = [
102 | 'group_id' => $groupId,
103 | 'tags' => $tags,
104 | 'user_id' => $userId,
105 | 'extras' => $extras,
106 | 'per_page' => $perPage,
107 | 'page' => $page
108 | ];
109 | return $this->flickr->request('flickr.groups.pools.getPhotos', $params);
110 | }
111 |
112 | /**
113 | * Remove a photo from a group pool.
114 | *
115 | * This method requires authentication.
116 | *
117 | * @link https://www.flickr.com/services/api/flickr.groups.pools.remove.html
118 | * @param string $photoId The id of the photo to remove from the group pool. The
119 | * photo must either be owned by the calling user of the calling user must be an
120 | * administrator of the group.
121 | * @param string $groupId The NSID of the group who's pool the photo is to removed
122 | * from.
123 | * @return
124 | */
125 | public function remove($photoId, $groupId)
126 | {
127 | $params = [
128 | 'photo_id' => $photoId,
129 | 'group_id' => $groupId
130 | ];
131 | return $this->flickr->request('flickr.groups.pools.remove', $params);
132 | }
133 | }
134 |
--------------------------------------------------------------------------------
/src/MachinetagsApi.php:
--------------------------------------------------------------------------------
1 | $predicate,
26 | 'per_page' => $perPage,
27 | 'page' => $page
28 | ];
29 | return $this->flickr->request('flickr.machinetags.getNamespaces', $params);
30 | }
31 |
32 | /**
33 | * Return a list of unique namespace and predicate pairs, optionally limited by
34 | * predicate or namespace, in alphabetical order.
35 | *
36 | * This method does not require authentication.
37 | *
38 | * @link https://www.flickr.com/services/api/flickr.machinetags.getPairs.html
39 | * @param string $namespace Limit the list of pairs returned to those that have the
40 | * following namespace.
41 | * @param string $predicate Limit the list of pairs returned to those that have the
42 | * following predicate.
43 | * @param string $perPage Number of photos to return per page. If this argument is
44 | * omitted, it defaults to 100. The maximum allowed value is 500.
45 | * @param string $page The page of results to return. If this argument is omitted,
46 | * it defaults to 1.
47 | * @return
48 | */
49 | public function getPairs($namespace = null, $predicate = null, $perPage = null, $page = null)
50 | {
51 | $params = [
52 | 'namespace' => $namespace,
53 | 'predicate' => $predicate,
54 | 'per_page' => $perPage,
55 | 'page' => $page
56 | ];
57 | return $this->flickr->request('flickr.machinetags.getPairs', $params);
58 | }
59 |
60 | /**
61 | * Return a list of unique predicates, optionally limited by a given namespace.
62 | *
63 | * This method does not require authentication.
64 | *
65 | * @link https://www.flickr.com/services/api/flickr.machinetags.getPredicates.html
66 | * @param string $namespace Limit the list of predicates returned to those that
67 | * have the following namespace.
68 | * @param string $perPage Number of photos to return per page. If this argument is
69 | * omitted, it defaults to 100. The maximum allowed value is 500.
70 | * @param string $page The page of results to return. If this argument is omitted,
71 | * it defaults to 1.
72 | * @return
73 | */
74 | public function getPredicates($namespace = null, $perPage = null, $page = null)
75 | {
76 | $params = [
77 | 'namespace' => $namespace,
78 | 'per_page' => $perPage,
79 | 'page' => $page
80 | ];
81 | return $this->flickr->request('flickr.machinetags.getPredicates', $params);
82 | }
83 |
84 | /**
85 | * Fetch recently used (or created) machine tags values.
86 | *
87 | * This method does not require authentication.
88 | *
89 | * @link https://www.flickr.com/services/api/flickr.machinetags.getRecentValues.html
90 | * @param string $namespace A namespace that all values should be restricted to.
91 | * @param string $predicate A predicate that all values should be restricted to.
92 | * @param string $addedSince Only return machine tags values that have been added
93 | * since this timestamp, in epoch seconds.
94 | * @return
95 | */
96 | public function getRecentValues($namespace = null, $predicate = null, $addedSince = null)
97 | {
98 | $params = [
99 | 'namespace' => $namespace,
100 | 'predicate' => $predicate,
101 | 'added_since' => $addedSince
102 | ];
103 | return $this->flickr->request('flickr.machinetags.getRecentValues', $params);
104 | }
105 |
106 | /**
107 | * Return a list of unique values for a namespace and predicate.
108 | *
109 | * This method does not require authentication.
110 | *
111 | * @link https://www.flickr.com/services/api/flickr.machinetags.getValues.html
112 | * @param string $namespace The namespace that all values should be restricted to.
113 | * @param string $predicate The predicate that all values should be restricted to.
114 | * @param string $perPage Number of photos to return per page. If this argument is
115 | * omitted, it defaults to 100. The maximum allowed value is 500.
116 | * @param string $page The page of results to return. If this argument is omitted,
117 | * it defaults to 1.
118 | * @return
119 | */
120 | public function getValues($namespace, $predicate, $perPage = null, $page = null)
121 | {
122 | $params = [
123 | 'namespace' => $namespace,
124 | 'predicate' => $predicate,
125 | 'per_page' => $perPage,
126 | 'page' => $page
127 | ];
128 | return $this->flickr->request('flickr.machinetags.getValues', $params);
129 | }
130 | }
131 |
--------------------------------------------------------------------------------
/src/GroupsApi.php:
--------------------------------------------------------------------------------
1 | $catId
22 | ];
23 | return $this->flickr->request('flickr.groups.browse', $params);
24 | }
25 |
26 | /**
27 | * Get information about a group.
28 | *
29 | * This method does not require authentication.
30 | *
31 | * @link https://www.flickr.com/services/api/flickr.groups.getInfo.html
32 | * @param string $groupId The NSID of the group to fetch information for.
33 | * @param string $groupPathAlias The path alias of the group. One of this or the
34 | * group_id param is required
35 | * @param string $lang The language of the group name and description to fetch. If
36 | * the language is not found, the primary language of the group will be returned.
37 | * Valid values are the same as in feeds.
38 | * @return
39 | */
40 | public function getInfo($groupId, $groupPathAlias = null, $lang = null)
41 | {
42 | $params = [
43 | 'group_id' => $groupId,
44 | 'group_path_alias' => $groupPathAlias,
45 | 'lang' => $lang
46 | ];
47 | return $this->flickr->request('flickr.groups.getInfo', $params);
48 | }
49 |
50 | /**
51 | * Join a public group as a member.
52 | *
53 | * This method requires authentication.
54 | *
55 | * @link https://www.flickr.com/services/api/flickr.groups.join.html
56 | * @param string $groupId The NSID of the Group in question
57 | * @param string $acceptRules If the group has rules, they must be displayed to the
58 | * user prior to joining. Passing a true value for this argument specifies that the
59 | * application has displayed the group rules to the user, and that the user has
60 | * agreed to them. (See flickr.groups.getInfo).
61 | * @return
62 | */
63 | public function join($groupId, $acceptRules = null)
64 | {
65 | $params = [
66 | 'group_id' => $groupId,
67 | 'accept_rules' => $acceptRules
68 | ];
69 | return $this->flickr->request('flickr.groups.join', $params);
70 | }
71 |
72 | /**
73 | * Request to join a group that is invitation-only.
74 | *
75 | * This method requires authentication.
76 | *
77 | * @link https://www.flickr.com/services/api/flickr.groups.joinRequest.html
78 | * @param string $groupId The NSID of the group to request joining.
79 | * @param string $message Message to the administrators.
80 | * @param string $acceptRules If the group has rules, they must be displayed to the
81 | * user prior to joining. Passing a true value for this argument specifies that the
82 | * application has displayed the group rules to the user, and that the user has
83 | * agreed to them. (See flickr.groups.getInfo).
84 | * @return
85 | */
86 | public function joinRequest($groupId, $message, $acceptRules)
87 | {
88 | $params = [
89 | 'group_id' => $groupId,
90 | 'message' => $message,
91 | 'accept_rules' => $acceptRules
92 | ];
93 | return $this->flickr->request('flickr.groups.joinRequest', $params);
94 | }
95 |
96 | /**
97 | * Leave a group.
98 |
99 | day and week (defaults to day).
52 | * @param string $count The number of tags to return. Defaults to 20. Maximum
53 | * allowed value is 200.
54 | * @return
55 | */
56 | public function getHotList($period = null, $count = null)
57 | {
58 | $params = [
59 | 'period' => $period,
60 | 'count' => $count
61 | ];
62 | return $this->flickr->request('flickr.tags.getHotList', $params);
63 | }
64 |
65 | /**
66 | * Get the tag list for a given photo.
67 | *
68 | * This method does not require authentication.
69 | *
70 | * @link https://www.flickr.com/services/api/flickr.tags.getListPhoto.html
71 | * @param string $photoId The id of the photo to return tags for.
72 | * @return
73 | */
74 | public function getListPhoto($photoId)
75 | {
76 | $params = [
77 | 'photo_id' => $photoId
78 | ];
79 | return $this->flickr->request('flickr.tags.getListPhoto', $params);
80 | }
81 |
82 | /**
83 | * Get the tag list for a given user (or the currently logged in user).
84 | *
85 | * This method does not require authentication.
86 | *
87 | * @link https://www.flickr.com/services/api/flickr.tags.getListUser.html
88 | * @param string $userId The NSID of the user to fetch the tag list for. If this
89 | * argument is not specified, the currently logged in user (if any) is assumed.
90 | * @return
91 | */
92 | public function getListUser($userId = null)
93 | {
94 | $params = [
95 | 'user_id' => $userId
96 | ];
97 | return $this->flickr->request('flickr.tags.getListUser', $params);
98 | }
99 |
100 | /**
101 | * Get the popular tags for a given user (or the currently logged in user).
102 | *
103 | * This method does not require authentication.
104 | *
105 | * @link https://www.flickr.com/services/api/flickr.tags.getListUserPopular.html
106 | * @param string $userId The NSID of the user to fetch the tag list for. If this
107 | * argument is not specified, the currently logged in user (if any) is assumed.
108 | * @param string $count Number of popular tags to return. defaults to 10 when this
109 | * argument is not present.
110 | * @return
111 | */
112 | public function getListUserPopular($userId = null, $count = null)
113 | {
114 | $params = [
115 | 'user_id' => $userId,
116 | 'count' => $count
117 | ];
118 | return $this->flickr->request('flickr.tags.getListUserPopular', $params);
119 | }
120 |
121 | /**
122 | * Get the raw versions of a given tag (or all tags) for the currently logged-in
123 | * user.
124 | *
125 | * This method does not require authentication.
126 | *
127 | * @link https://www.flickr.com/services/api/flickr.tags.getListUserRaw.html
128 | * @param string $tag The tag you want to retrieve all raw versions for.
129 | * @return
130 | */
131 | public function getListUserRaw($tag = null)
132 | {
133 | $params = [
134 | 'tag' => $tag
135 | ];
136 | return $this->flickr->request('flickr.tags.getListUserRaw', $params);
137 | }
138 |
139 | /**
140 | * Returns a list of most frequently used tags for a user.
141 | *
142 | * This method requires authentication.
143 | *
144 | * @link https://www.flickr.com/services/api/flickr.tags.getMostFrequentlyUsed.html
145 | *
146 | * @return
147 | */
148 | public function getMostFrequentlyUsed()
149 | {
150 | return $this->flickr->request('flickr.tags.getMostFrequentlyUsed');
151 | }
152 |
153 | /**
154 | * Returns a list of tags 'related' to the given tag, based on clustered usage
155 | * analysis.
156 | *
157 | * This method does not require authentication.
158 | *
159 | * @link https://www.flickr.com/services/api/flickr.tags.getRelated.html
160 | * @param string $tag The tag to fetch related tags for.
161 | * @return
162 | */
163 | public function getRelated($tag)
164 | {
165 | $params = [
166 | 'tag' => $tag
167 | ];
168 | return $this->flickr->request('flickr.tags.getRelated', $params);
169 | }
170 | }
171 |
--------------------------------------------------------------------------------
/src/Uploader.php:
--------------------------------------------------------------------------------
1 | flickr = $flickr;
28 | }
29 |
30 | /**
31 | * Upload a photo.
32 | * @link https://www.flickr.com/services/api/upload.api.html
33 | * @param string $photoFilename Full filesystem path to the photo to upload.
34 | * @param string|null $title The title of the photo.
35 | * @param string|null $description A description of the photo. May contain some limited HTML.
36 | * @param string|null $tags A space-seperated list of tags to apply to the photo.
37 | * @param bool|null $isPublic Specifies who can view the photo. If omitted permissions will
38 | * be set to user's default.
39 | * @param bool|null $isFriend Specifies who can view the photo. If omitted permissions will
40 | * be set to user's default.
41 | * @param bool|null $isFamily Specifies who can view the photo. If omitted permissions will
42 | * be set to user's default.
43 | * @param int|null $contentType Set to 1 for Photo, 2 for Screenshot, or 3 for Other. If
44 | * omitted , will be set to user's default.
45 | * @param int|null $hidden Set to 1 to keep the photo in global search results, 2 to hide from
46 | * public searches. If omitted, will be set based to user's default.
47 | * @param bool $async Whether to upload the file asynchronously (in which case a 'ticketid'
48 | * will be returned).
49 | * @return string[]
50 | */
51 | public function upload(
52 | $photoFilename,
53 | $title = null,
54 | $description = null,
55 | $tags = null,
56 | $isPublic = null,
57 | $isFriend = null,
58 | $isFamily = null,
59 | $contentType = null,
60 | $hidden = null,
61 | $async = false
62 | ) {
63 | $params = [
64 | 'title' => $title,
65 | 'description' => $description,
66 | 'tags' => $tags,
67 | 'is_public' => $isPublic,
68 | 'is_friend' => $isFriend,
69 | 'is_family' => $isFamily,
70 | 'content_type' => $contentType,
71 | 'hidden' => $hidden,
72 | ];
73 | if ($async) {
74 | $params['async'] = 1;
75 | }
76 | return $this->sendFile($photoFilename, $params);
77 | }
78 |
79 | /**
80 | * @link https://www.flickr.com/services/api/replace.api.html
81 | * @param string $photoFilename Full filesystem path to the file to upload.
82 | * @param int $photoId The ID of the photo to replace.
83 | * @param bool $async Photos may be replaced in async mode, for applications that don't want to
84 | * wait around for an upload to complete, leaving a socket connection open the whole time.
85 | * Processing photos asynchronously is recommended.
86 | * @return string[]
87 | */
88 | public function replace($photoFilename, $photoId, $async = null)
89 | {
90 | return $this->sendFile($photoFilename, ['photo_id' => $photoId, 'async' => $async]);
91 | }
92 |
93 | /**
94 | * @param string $filename
95 | * @param array $params
96 | * @return array
97 | * @throws Exception If an OAuth error occurs.
98 | * @throws FlickrException If the file can't be read.
99 | */
100 | protected function sendFile($filename, $params)
101 | {
102 | if (!is_readable($filename)) {
103 | throw new FlickrException("File not readable: $filename");
104 | }
105 | $args = $this->flickr
106 | ->getOauthService()
107 | ->getAuthorizationForPostingToAlternateUrl($params, $this->uploadEndpoint);
108 | // The 'photo' parameter can't be part of the authorization signature, so we add it now.
109 | $args['photo'] = new CURLFile(realpath($filename));
110 |
111 | $curl = curl_init($this->uploadEndpoint);
112 | curl_setopt($curl, CURLOPT_POST, true);
113 | curl_setopt($curl, CURLOPT_POSTFIELDS, $args);
114 | curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
115 | curl_setopt($curl, CURLOPT_USERAGENT, $this->flickr->getUserAgent());
116 | $response = curl_exec($curl);
117 | $this->response = $response;
118 | curl_close($curl);
119 |
120 | // Some OAuth errors are not in an XML format, but instead look
121 | // like e.g. oauth_problem=token_rejected
122 | if (1 === preg_match('/oauth_problem=(.*)/', $response, $matches)) {
123 | throw new OauthException($matches[1]);
124 | }
125 |
126 | // Process result.
127 | $xml = simplexml_load_string($response);
128 | $uploadResponse = ['stat' => (string)$xml['stat'][0]];
129 | if (isset($xml->photoid)) {
130 | $uploadResponse['photoid'] = (int)$xml->photoid;
131 | }
132 | if (isset($xml->photoid['secret'])) {
133 | $uploadResponse['secret'] = (string)$xml->photoid['secret'];
134 | }
135 | if (isset($xml->photoid['originalsecret'])) {
136 | $uploadResponse['originalsecret'] = (string)$xml->photoid['originalsecret'];
137 | }
138 | if (isset($xml->ticketid)) {
139 | $uploadResponse['ticketid'] = (string)$xml->ticketid;
140 | }
141 | if (isset($xml->err)) {
142 | $uploadResponse['code'] = (int)$xml->err['code'];
143 | $uploadResponse['message'] = (string)$xml->err['msg'];
144 | }
145 | return $uploadResponse;
146 | }
147 | }
148 |
--------------------------------------------------------------------------------
/src/FavoritesApi.php:
--------------------------------------------------------------------------------
1 | $photoId
20 | ];
21 | return $this->flickr->request('flickr.favorites.add', $params);
22 | }
23 |
24 | /**
25 | * Returns next and previous favorites for a photo in a user's favorites.
26 | *
27 | * This method does not require authentication.
28 | *
29 | * @link https://www.flickr.com/services/api/flickr.favorites.getContext.html
30 | * @param string $photoId The id of the photo to fetch the context for.
31 | * @param string $userId The user who counts the photo as a favorite.
32 | * @return
33 | */
34 | public function getContext($photoId, $userId)
35 | {
36 | $params = [
37 | 'photo_id' => $photoId,
38 | 'user_id' => $userId
39 | ];
40 | return $this->flickr->request('flickr.favorites.getContext', $params);
41 | }
42 |
43 | /**
44 | * Returns a list of the user's favorite photos. Only photos which the calling user
45 | * has permission to see are returned.
46 | *
47 | * This method does not require authentication.
48 | *
49 | * @link https://www.flickr.com/services/api/flickr.favorites.getList.html
50 | * @param string $userId The NSID of the user to fetch the favorites list for. If
51 | * this argument is omitted, the favorites list for the calling user is returned.
52 | * @param string $minFaveDate Minimum date that a photo was favorited on. The date
53 | * should be in the form of a unix timestamp.
54 | * @param string $maxFaveDate Maximum date that a photo was favorited on. The date
55 | * should be in the form of a unix timestamp.
56 | * @param string $extras A comma-delimited list of extra information to fetch for
57 | * each returned record. Currently supported fields are: description,
58 | * license, date_upload, date_taken,
59 | * owner_name, icon_server, original_format,
60 | * last_update, geo, tags,
61 | * machine_tags, o_dims, views,
62 | * media, path_alias, url_sq,
63 | * url_t, url_s, url_q, url_m,
64 | * url_n, url_z, url_c, url_l,
65 | * url_o
66 | * @param string $perPage Number of photos to return per page. If this argument is
67 | * omitted, it defaults to 100. The maximum allowed value is 500.
68 | * @param string $page The page of results to return. If this argument is omitted,
69 | * it defaults to 1.
70 | * @return
71 | */
72 | public function getList(
73 | $userId = null,
74 | $minFaveDate = null,
75 | $maxFaveDate = null,
76 | $extras = null,
77 | $perPage = null,
78 | $page = null
79 | ) {
80 | $params = [
81 | 'user_id' => $userId,
82 | 'min_fave_date' => $minFaveDate,
83 | 'max_fave_date' => $maxFaveDate,
84 | 'extras' => $extras,
85 | 'per_page' => $perPage,
86 | 'page' => $page
87 | ];
88 | return $this->flickr->request('flickr.favorites.getList', $params);
89 | }
90 |
91 | /**
92 | * Returns a list of favorite public photos for the given user.
93 | *
94 | * This method does not require authentication.
95 | *
96 | * @link https://www.flickr.com/services/api/flickr.favorites.getPublicList.html
97 | * @param string $userId The user to fetch the favorites list for.
98 | * @param string $minFaveDate Minimum date that a photo was favorited on. The date
99 | * should be in the form of a unix timestamp.
100 | * @param string $maxFaveDate Maximum date that a photo was favorited on. The date
101 | * should be in the form of a unix timestamp.
102 | * @param string $extras A comma-delimited list of extra information to fetch for
103 | * each returned record. Currently supported fields are: description,
104 | * license, date_upload, date_taken,
105 | * owner_name, icon_server, original_format,
106 | * last_update, geo, tags,
107 | * machine_tags, o_dims, views,
108 | * media, path_alias, url_sq,
109 | * url_t, url_s, url_q, url_m,
110 | * url_n, url_z, url_c, url_l,
111 | * url_o
112 | * @param string $perPage Number of photos to return per page. If this argument is
113 | * omitted, it defaults to 100. The maximum allowed value is 500.
114 | * @param string $page The page of results to return. If this argument is omitted,
115 | * it defaults to 1.
116 | * @return
117 | */
118 | public function getPublicList(
119 | $userId,
120 | $minFaveDate = null,
121 | $maxFaveDate = null,
122 | $extras = null,
123 | $perPage = null,
124 | $page = null
125 | ) {
126 | $params = [
127 | 'user_id' => $userId,
128 | 'min_fave_date' => $minFaveDate,
129 | 'max_fave_date' => $maxFaveDate,
130 | 'extras' => $extras,
131 | 'per_page' => $perPage,
132 | 'page' => $page
133 | ];
134 | return $this->flickr->request('flickr.favorites.getPublicList', $params);
135 | }
136 |
137 | /**
138 | * Removes a photo from a user's favorites list.
139 | *
140 | * This method requires authentication.
141 | *
142 | * @link https://www.flickr.com/services/api/flickr.favorites.remove.html
143 | * @param string $photoId The id of the photo to remove from the user's favorites.
144 | * @return
145 | */
146 | public function remove($photoId)
147 | {
148 | $params = [
149 | 'photo_id' => $photoId
150 | ];
151 | return $this->flickr->request('flickr.favorites.remove', $params);
152 | }
153 | }
154 |
--------------------------------------------------------------------------------
/src/PushApi.php:
--------------------------------------------------------------------------------
1 | flickr->request('flickr.push.getSubscriptions');
19 | }
20 |
21 | /**
22 | * All the different flavours of anteater. This method is experimental and may change.
23 | *
24 | * This method does not require authentication.
25 | *
26 | * @link https://www.flickr.com/services/api/flickr.push.getTopics.html
27 | *
28 | * @return
29 | */
30 | public function getTopics()
31 | {
32 | return $this->flickr->request('flickr.push.getTopics');
33 | }
34 |
35 | /**
36 | * In ur pandas, tickling ur unicorn
37 | sync or
50 | * async. See the Google
52 | * PubSubHubbub spec for details.
53 | * @param string $verifyToken The verification token to be echoed back to the
54 | * subscriber during the verification callback, as per the Google
56 | * PubSubHubbub spec. Limited to 200 bytes.
57 | * @param string $leaseSeconds Number of seconds for which the subscription will be
58 | * valid. Legal values are 60 to 86400 (1 minute to 1 day). If not present, the
59 | * subscription will be auto-renewing.
60 | * @param string $woeIds A 32-bit integer for a Where on Earth ID. Only
62 | * valid if topic is geo. lat, lon parameters will be ignored if place_ids is
65 | * present, which will be ignored if woe_ids is present.
66 | * @param string $placeIds A comma-separated list of Flickr place IDs. Only valid
67 | * if topic is geo. lat,
69 | * lon parameters will be ignored if place_ids is present,
70 | * which will be ignored if woe_ids is present.
71 | * @param string $lat A latitude value, in decimal format. Only valid if
72 | * topic is geo. Defines the latitude for a radial query
73 | * centered around (lat, lon). lat, lon
75 | * parameters will be ignored if place_ids is present, which will be
76 | * ignored if woe_ids is present.
77 | * @param string $lon A longitude value, in decimal format. Only valid if
78 | * topic is geo. Defines the longitude for a radial query
79 | * centered around (lat, lon). lat, lon
81 | * parameters will be ignored if place_ids is present, which will be
82 | * ignored if woe_ids is present.
83 | * @param string $radius A radius value, in the units defined by radius_units. Only
84 | * valid if topic is geo. Defines the radius of a circle
85 | * for a radial query centered around (lat, lon). Default is 5 km. lat, lon parameters will be ignored if place_ids
88 | * is present, which will be ignored if woe_ids is present.
89 | * @param string $radiusUnits Defines the units for the radius parameter. Only
90 | * valid if topic is geo. Options are mi and
91 | * km. Default is km. lat,
93 | * lon parameters will be ignored if place_ids is present,
94 | * which will be ignored if woe_ids is present.
95 | * @param string $accuracy Defines the minimum accuracy required for photos to be
96 | * included in a subscription. Only valid if topic is geo
97 | * Legal values are 1-16, default is 1 (i.e. any accuracy level). topic is commons. If not present this
104 | * argument defaults to all Flickr Commons institutions.
105 | * @param string $tags A comma-separated list of strings to be used for tag
106 | * subscriptions. Photos with one or more of the tags listed will be included in
107 | * the subscription. Only valid if the topic is tags.
108 | * @return
109 | */
110 | public function subscribe(
111 | $topic,
112 | $callback,
113 | $verify,
114 | $verifyToken = null,
115 | $leaseSeconds = null,
116 | $woeIds = null,
117 | $placeIds = null,
118 | $lat = null,
119 | $lon = null,
120 | $radius = null,
121 | $radiusUnits = null,
122 | $accuracy = null,
123 | $nsids = null,
124 | $tags = null
125 | ) {
126 | $params = [
127 | 'topic' => $topic,
128 | 'callback' => $callback,
129 | 'verify' => $verify,
130 | 'verify_token' => $verifyToken,
131 | 'lease_seconds' => $leaseSeconds,
132 | 'woe_ids' => $woeIds,
133 | 'place_ids' => $placeIds,
134 | 'lat' => $lat,
135 | 'lon' => $lon,
136 | 'radius' => $radius,
137 | 'radius_units' => $radiusUnits,
138 | 'accuracy' => $accuracy,
139 | 'nsids' => $nsids,
140 | 'tags' => $tags
141 | ];
142 | return $this->flickr->request('flickr.push.subscribe', $params);
143 | }
144 |
145 | /**
146 | * Why would you want to do this?
147 | description,
121 | * license, date_upload, date_taken,
122 | * owner_name, icon_server, original_format,
123 | * last_update, geo, tags,
124 | * machine_tags, o_dims, views,
125 | * media, path_alias, url_sq,
126 | * url_t, url_s, url_q, url_m,
127 | * url_n, url_z, url_c, url_l,
128 | * url_o
129 | * @param string $perPage Number of photos to return per page. If this argument is
130 | * omitted, it defaults to 100. The maximum allowed value is 500.
131 | * @param string $page The page of results to return. If this argument is omitted,
132 | * it defaults to 1.
133 | * @return
134 | */
135 | public function photosForLocation($lat, $lon, $accuracy = null, $extras = null, $perPage = null, $page = null)
136 | {
137 | $params = [
138 | 'lat' => $lat,
139 | 'lon' => $lon,
140 | 'accuracy' => $accuracy,
141 | 'extras' => $extras,
142 | 'per_page' => $perPage,
143 | 'page' => $page
144 | ];
145 | return $this->flickr->request('flickr.photos.geo.photosForLocation', $params);
146 | }
147 |
148 | /**
149 | * Removes the geo data associated with a photo.
150 | *
151 | * This method requires authentication.
152 | *
153 | * @link https://www.flickr.com/services/api/flickr.photos.geo.removeLocation.html
154 | * @param string $photoId The id of the photo you want to remove location data
155 | * from.
156 | * @return
157 | */
158 | public function removeLocation($photoId)
159 | {
160 | $params = [
161 | 'photo_id' => $photoId
162 | ];
163 | return $this->flickr->request('flickr.photos.geo.removeLocation', $params);
164 | }
165 |
166 | /**
167 | * Indicate the state of a photo's geotagginess beyond latitude and longitude.flickr.photos.geo.setLocationmethod). 171 | * 172 | * This method requires authentication. 173 | * 174 | * @link https://www.flickr.com/services/api/flickr.photos.geo.setContext.html 175 | * @param string $photoId The id of the photo to set context data for. 176 | * @param string $context Context is a numeric value representing the photo's 177 | * geotagginess beyond latitude and longitude. For example, you may wish to 178 | * indicate that a photo was taken "indoors" or "outdoors".
privacy,
52 | * throttle, restrictions
53 | * @return
54 | */
55 | public function getGroups($userId, $extras = null)
56 | {
57 | $params = [
58 | 'user_id' => $userId,
59 | 'extras' => $extras
60 | ];
61 | return $this->flickr->request('flickr.people.getGroups', $params);
62 | }
63 |
64 | /**
65 | * Get information about a user.
66 | *
67 | * This method does not require authentication.
68 | *
69 | * @link https://www.flickr.com/services/api/flickr.people.getInfo.html
70 | * @param string $userId The NSID of the user to fetch information about.
71 | * @return
72 | */
73 | public function getInfo($userId)
74 | {
75 | $params = [
76 | 'user_id' => $userId
77 | ];
78 | $response = $this->flickr->request('flickr.people.getInfo', $params);
79 | return isset($response['person']) ? $response['person'] : null;
80 | }
81 |
82 | /**
83 | * Returns the photo and video limits that apply to the calling user account.
84 | *
85 | * This method requires authentication.
86 | *
87 | * @link https://www.flickr.com/services/api/flickr.people.getLimits.html
88 | *
89 | * @return
90 | */
91 | public function getLimits()
92 | {
93 | return $this->flickr->request('flickr.people.getLimits');
94 | }
95 |
96 | /**
97 | * Return photos from the given user's photostream.
98 | * Only photos visible to the calling user will be returned.
99 | * This method must be authenticated;
100 | * to return public photos for a user, use self::getPublicPhotos().
101 | * @link https://www.flickr.com/services/api/flickr.people.getPhotos.html
102 | * @param string $userId The NSID of the user who's photos to return. A value of
103 | * "me" will return the calling user's photos.
104 | * @param int $safeSearch Safe search setting: 1 for safe. 2 for moderate. 3 for
105 | * restricted. (Please note: Un-authed calls can only see Safe content.)
106 | * @param string $minUploadDate Minimum upload date. Photos with an upload date greater than or
107 | * equal to this value will be returned. The date should be in the form of a unix timestamp.
108 | * @param string $maxUploadDate Maximum upload date. Photos with an upload date less than or
109 | * equal to this value will be returned. The date should be in the form of a unix timestamp.
110 | * @param string $minTakenDate Minimum taken date. Photos with an taken date greater than or
111 | * equal to this value will be returned. The date should be in the form of a mysql datetime.
112 | * @param string $maxTakenDate Maximum taken date. Photos with an taken date less than or equal
113 | * to this value will be returned. The date should be in the form of a mysql datetime.
114 | * @param int $contentType Content Type setting:
115 | * 1 for photos only.
116 | * 2 for screenshots only.
117 | * 3 for 'other' only.
118 | * 4 for photos and screenshots.
119 | * 5 for screenshots and 'other'.
120 | * 6 for photos and 'other'.
121 | * 7 for photos, screenshots, and 'other' (all).
122 | * @param int $privacyFilter Return photos only matching a certain privacy level. This only
123 | * applies when making an authenticated call to view photos you own. Valid values are:
124 | * 1 public photos
125 | * 2 private photos visible to friends
126 | * 3 private photos visible to family
127 | * 4 private photos visible to friends & family
128 | * 5 completely private photos
129 | * @param string $extras A comma-delimited list of extra information to fetch for each
130 | * returned record. Currently supported fields are: description, license, date_upload,
131 | * date_taken, owner_name, icon_server, original_format, last_update, geo, tags, machine_tags,
132 | * o_dims, views, media, path_alias, url_sq, url_t, url_s, url_q, url_m, url_n, url_z, url_c,
133 | * url_l, url_o
134 | * @param int $perPage Number of photos to return per page. The maximum allowed value is 500.
135 | * @param int $page The page of results to return.
136 | * @return string[]|bool Photo information, or false if none.
137 | */
138 | public function getPhotos(
139 | $userId = 'me',
140 | $safeSearch = null,
141 | $minUploadDate = null,
142 | $maxUploadDate = null,
143 | $minTakenDate = null,
144 | $maxTakenDate = null,
145 | $contentType = null,
146 | $privacyFilter = null,
147 | $extras = null,
148 | $perPage = 100,
149 | $page = 1
150 | ) {
151 | $params = [
152 | 'user_id' => $userId,
153 | 'safe_search' => $safeSearch,
154 | 'min_upload_date' => $minUploadDate,
155 | 'max_upload_date' => $maxUploadDate,
156 | 'min_taken_date' => $minTakenDate,
157 | 'max_taken_date' => $maxTakenDate,
158 | 'content_type' => $contentType,
159 | 'privacy_filter' => $privacyFilter,
160 | 'extras' => $extras,
161 | 'per_page' => $perPage,
162 | 'page' => $page,
163 | ];
164 | $photos = $this->flickr->request('flickr.people.getPhotos', $params);
165 | return isset($photos['photos']) ? $photos['photos'] : false;
166 | }
167 |
168 | /**
169 | * Returns a list of photos containing a particular Flickr member.
170 | *
171 | * This method does not require authentication.
172 | *
173 | * @link https://www.flickr.com/services/api/flickr.people.getPhotosOf.html
174 | * @param string $userId The NSID of the user you want to find photos of. A value
175 | * of "me" will search against photos of the calling user, for authenticated calls.
176 | * @param string $ownerId An NSID of a Flickr member. This will restrict the list
177 | * of photos to those taken by that member.
178 | * @param string $extras A comma-delimited list of extra information to fetch for
179 | * each returned record. Currently supported fields are: description,
180 | * license, date_upload, date_taken,
181 | * date_person_added, owner_name,
182 | * icon_server, original_format,
183 | * last_update, geo, tags,
184 | * machine_tags, o_dims, views,
185 | * media, path_alias, url_sq,
186 | * url_t, url_s, url_q, url_m,
187 | * url_n, url_z, url_c, url_l,
188 | * url_o
189 | * @param string $perPage Number of photos to return per page. If this argument is
190 | * omitted, it defaults to 100. The maximum allowed value is 500.
191 | * @param string $page The page of results to return. If this argument is omitted,
192 | * it defaults to 1.
193 | * @return
194 | */
195 | public function getPhotosOf($userId, $ownerId = null, $extras = null, $perPage = null, $page = null)
196 | {
197 | $params = [
198 | 'user_id' => $userId,
199 | 'owner_id' => $ownerId,
200 | 'extras' => $extras,
201 | 'per_page' => $perPage,
202 | 'page' => $page,
203 | ];
204 | return $this->flickr->request('flickr.people.getPhotosOf', $params);
205 | }
206 |
207 | /**
208 | * Returns the list of public groups a user is a member of.
209 | *
210 | * This method does not require authentication.
211 | *
212 | * @link https://www.flickr.com/services/api/flickr.people.getPublicGroups.html
213 | * @param string $userId The NSID of the user to fetch groups for.
214 | * @param string $invitationOnly Include public groups that require an invitation or administrator
216 | * approval to join.
217 | * @return
218 | */
219 | public function getPublicGroups($userId, $invitationOnly = null)
220 | {
221 | $params = [
222 | 'user_id' => $userId,
223 | 'invitation_only' => $invitationOnly
224 | ];
225 | return $this->flickr->request('flickr.people.getPublicGroups', $params);
226 | }
227 |
228 | /**
229 | * Get a list of public photos for the given user.
230 | *
231 | * This method does not require authentication.
232 | *
233 | * @link https://www.flickr.com/services/api/flickr.people.getPublicPhotos.html
234 | * @param string $userId The NSID of the user who's photos to return.
235 | * @param string $safeSearch Safe search setting: description,
240 | * license, date_upload, date_taken,
241 | * owner_name, icon_server, original_format,
242 | * last_update, geo, tags,
243 | * machine_tags, o_dims, views,
244 | * media, path_alias, url_sq,
245 | * url_t, url_s, url_q, url_m,
246 | * url_n, url_z, url_c, url_l,
247 | * url_o
248 | * @param string $perPage Number of photos to return per page. If this argument is
249 | * omitted, it defaults to 100. The maximum allowed value is 500.
250 | * @param string $page The page of results to return. If this argument is omitted,
251 | * it defaults to 1.
252 | * @return
253 | */
254 | public function getPublicPhotos($userId, $safeSearch = null, $extras = null, $perPage = null, $page = null)
255 | {
256 | $params = [
257 | 'user_id' => $userId,
258 | 'safe_search' => $safeSearch,
259 | 'extras' => $extras,
260 | 'per_page' => $perPage,
261 | 'page' => $page
262 | ];
263 | return $this->flickr->request('flickr.people.getPublicPhotos', $params);
264 | }
265 |
266 | /**
267 | * Returns information for the calling user related to photo uploads.
268 | *
269 | * This method requires authentication.
270 | *
271 | * @link https://www.flickr.com/services/api/flickr.people.getUploadStatus.html
272 | *
273 | * @return
274 | */
275 | public function getUploadStatus()
276 | {
277 | return $this->flickr->request('flickr.people.getUploadStatus');
278 | }
279 | }
280 |
--------------------------------------------------------------------------------
/src/PhotosetsApi.php:
--------------------------------------------------------------------------------
1 | $photosetId,
21 | 'photo_id' => $photoId,
22 | ];
23 | $response = $this->flickr->request('flickr.photosets.addPhoto', $args, true);
24 | return (bool)$response;
25 | }
26 |
27 | /**
28 | * Create a new photoset for the calling user.
29 | * This method requires authentication with 'write' permission.
30 | * New photosets are automatically put first in the photoset ordering for the user.
31 | * @see PhotosetsApi::orderSets() if you don't want the new set to appear first on the user's
32 | * photoset list.
33 | * @link https://www.flickr.com/services/api/flickr.photosets.create.html
34 | * @param string $title A title for the photoset.
35 | * @param string $description A description of the photoset. May contain limited HTML.
36 | * @param int $primaryPhotoId The ID of the photo to represent this set. The photo must belong
37 | * to the calling user.
38 | * @return bool|mixed[]
39 | */
40 | public function create($title, $description, $primaryPhotoId)
41 | {
42 | $args = [
43 | 'title' => $title,
44 | 'primary_photo_id' => $primaryPhotoId,
45 | 'description' => $description,
46 | ];
47 | $response = $this->flickr->request('flickr.photosets.create', $args, true);
48 | return isset($response['photoset']) ? $response['photoset'] : false;
49 | }
50 |
51 | /**
52 | * Delete a photoset. This method requires authentication with 'write' permission.
53 | * @link https://www.flickr.com/services/api/flickr.photosets.delete.html
54 | * @param int $photosetId The id of the photoset to delete. It must be owned by the calling user.
55 | * @return bool
56 | */
57 | public function delete($photosetId)
58 | {
59 | $args = ['photoset_id' => $photosetId];
60 | return (bool)$this->flickr->request('flickr.photosets.delete', $args, true);
61 | }
62 |
63 | /**
64 | * Modify the meta-data for a photoset.
65 | *
66 | * This method requires authentication.
67 | *
68 | * @link https://www.flickr.com/services/api/flickr.photosets.editMeta.html
69 | * @param int $photosetId The ID of the photoset to modify.
70 | * @param string $title The new title for the photoset.
71 | * @param string|null $description A description of the photoset. May contain limited HTML.
72 | * @return bool
73 | */
74 | public function editMeta($photosetId, $title, $description = null)
75 | {
76 | $args = [
77 | 'photoset_id' => $photosetId,
78 | 'title' => $title,
79 | 'description' => $description,
80 | ];
81 | return (bool)$this->flickr->request('flickr.photosets.editMeta', $args, true);
82 | }
83 |
84 | /**
85 | * Modify the photos in a photoset. Use this method to add, remove and re-order photos.
86 | * This method requires authentication.
87 | * @link https://www.flickr.com/services/api/flickr.photosets.editPhotos.html
88 | * @param int $photosetId The ID of the photoset to modify. The photoset must belong to the
89 | * calling user.
90 | * @param int $primaryPhotoId The ID of the photo to use as the 'primary' photo for the set.
91 | * This ID must also be passed along in $photoIds parameter.
92 | * @param string|string[] $photoIds An array or comma-delimited list of photo IDs to include in
93 | * the set. They will appear in the set in the order sent. This list must contain the primary
94 | * photo ID. All photos must belong to the owner of the set. This list of photos replaces the
95 | * existing list. Call flickr.photosets.addPhoto to append a photo to a set.
96 | * @return bool
97 | */
98 | public function editPhotos($photosetId, $primaryPhotoId, $photoIds)
99 | {
100 | if (is_array($photoIds)) {
101 | $photoIds = join(',', $photoIds);
102 | }
103 | $args = [
104 | 'photoset_id' => $photosetId,
105 | 'primary_photo_id' => $primaryPhotoId,
106 | 'photo_ids' => $photoIds
107 | ];
108 | return (bool)$this->flickr->request('flickr.photosets.editPhotos', $args, true);
109 | }
110 |
111 | /**
112 | * Returns next and previous photos for a photo in a set.
113 | *
114 | * This method does not require authentication.
115 | *
116 | * @link https://www.flickr.com/services/api/flickr.photosets.getContext.html
117 | * @param int $photoId The ID of the photo to fetch the context for.
118 | * @param int $photosetId The ID of the photoset for which to fetch the photo's context.
119 | * @return mixed[] Array with 'prevphoto' and 'nextphoto' keys.
120 | */
121 | public function getContext($photoId, $photosetId)
122 | {
123 | $args = [
124 | 'photo_id' => $photoId,
125 | 'photoset_id' => $photosetId,
126 | ];
127 | return $this->flickr->request('flickr.photosets.getContext', $args);
128 | }
129 |
130 | /**
131 | * Gets information about a photoset.
132 | *
133 | * This method does not require authentication.
134 | *
135 | * @link https://www.flickr.com/services/api/flickr.photosets.getInfo.html
136 | * @param int $photosetId The ID of the photoset to fetch information for.
137 | * @param string $userId The ID of the owner of the set passed in $photosetId.
138 | * @return mixed[]|bool
139 | */
140 | public function getInfo($photosetId, $userId)
141 | {
142 | $args = [
143 | 'photoset_id' => $photosetId,
144 | 'user_id' => $userId,
145 | ];
146 | $response = $this->flickr->request('flickr.photosets.getInfo', $args);
147 | return isset($response['photoset']) ? $response['photoset'] : false;
148 | }
149 |
150 | /**
151 | * Returns the photosets belonging to the specified user.
152 | *
153 | * This method does not require authentication.
154 | *
155 | * @link https://www.flickr.com/services/api/flickr.photosets.getList.html
156 | * @param string $userId The NSID of the user to get a photoset list for. If none is
157 | * specified, the calling user is assumed.
158 | * @param int $page The page of results to get. Currently, if this is not provided, all sets are
159 | * returned, but this behaviour may change in future.
160 | * @param int $perPage The number of sets to get per page. If paging is enabled, the maximum
161 | * number of sets per page is 500.
162 | * @param string $primaryPhotoExtras A comma-delimited list of extra information to fetch for
163 | * the primary photo. Currently supported fields are: license, date_upload, date_taken,
164 | * owner_name, icon_server, original_format, last_update, geo, tags, machine_tags, o_dims,
165 | * views, media, path_alias, url_sq, url_t, url_s, url_m, url_o
166 | * @param string $photoIds A comma-separated list of photo ids. If specified, each returned set
167 | * will include a list of these photo IDs that are present in the set as
168 | * "has_requested_photos".
169 | * @param string $sortGroups A comma-separated list of groups used to sort the output sets. If has_photo is present,
170 | * any of the calling user's galleries containing photos referred to in photo_ids will be returned before other
171 | * galleries. The order of the sort_groups will dictate the order that the groups are returned in. Only available if
172 | * continuation is used. The resulting output will include a "sort_group" parameter indicating the sort_group that
173 | * each set is part of, or null if not applicable.
174 | * @return mixed[]|bool
175 | */
176 | public function getList(
177 | $userId = null,
178 | $page = null,
179 | $perPage = null,
180 | $primaryPhotoExtras = null,
181 | $photoIds = null,
182 | $sortGroups = null
183 | ) {
184 | $args = [
185 | 'user_id' => $userId,
186 | 'page' => $page,
187 | 'per_page' => $perPage,
188 | 'primary_photo_extras' => $primaryPhotoExtras,
189 | 'photo_ids' => $photoIds,
190 | 'sort_groups' => $sortGroups,
191 | ];
192 | $response = $this->flickr->request('flickr.photosets.getList', $args);
193 | return isset($response['photosets']) ? $response['photosets'] : false;
194 | }
195 |
196 | /**
197 | * Get the list of photos in a set.
198 | *
199 | * This method does not require authentication.
200 | *
201 | * @link https://www.flickr.com/services/api/flickr.photosets.getPhotos.html
202 | * @param int $photosetId The photoset ID.
203 | * @param string $userId The owner of the photo set.
204 | * @param string|string[] $extras Extra information to fetch for each photo. Comma-delimited string or array of
205 | * strings. Possible values: license, date_upload, date_taken, owner_name, icon_server, original_format,
206 | * last_update, geo, tags, machine_tags, o_dims, views, media, path_alias, url_sq, url_t, url_s, url_m, and url_o.
207 | * @param int $perPage The number of results per page. Default and maximum are 500.
208 | * @param int $page Which page of results to return.
209 | * @param int $privacyFilter Return photos matching one of the following privacy levels:
210 | * 1 public photos;
211 | * 2 private photos visible to friends;
212 | * 3 private photos visible to family;
213 | * 4 private photos visible to friends & family;
214 | * 5 completely private photos.
215 | * @param string $media Filter results by media type. One of 'all', 'photos', or 'videos'.
216 | * @return array[]|bool
217 | */
218 | public function getPhotos(
219 | $photosetId,
220 | $userId = null,
221 | $extras = null,
222 | $perPage = null,
223 | $page = null,
224 | $privacyFilter = null,
225 | $media = null
226 | ) {
227 | if (is_array($extras)) {
228 | $extras = join(',', $extras);
229 | }
230 | $args = [
231 | 'photoset_id' => $photosetId,
232 | 'user_id' => $userId,
233 | 'extras' => $extras,
234 | 'per_page' => $perPage,
235 | 'page' => $page,
236 | 'privacy_filter' => $privacyFilter,
237 | 'media' => $media,
238 | ];
239 | $response = $this->flickr->request('flickr.photosets.getPhotos', $args);
240 | return isset($response['photoset']) ? $response['photoset'] : false;
241 | }
242 |
243 | /**
244 | * Set the order of photosets for the calling user.
245 | *
246 | * This method requires authentication.
247 | *
248 | * @link https://www.flickr.com/services/api/flickr.photosets.orderSets.html
249 | * @param $photosetIds string|string[] An array or comma-delimited list of photoset IDs, ordered with the set to
250 | * show first, first in the list. Any set IDs not given in the list will be set to appear at the end of the list,
251 | * ordered by their IDs.
252 | * @return bool
253 | */
254 | public function orderSets($photosetIds)
255 | {
256 | if (is_array($photosetIds)) {
257 | $photosetIds = implode(",", $photosetIds);
258 | }
259 | $response = $this->flickr->request("flickr.photosets.orderSets", ["photoset_ids" => $photosetIds], true);
260 | return isset($response['stat']) && $response['stat'] === 'ok';
261 | }
262 |
263 | /**
264 | * Remove a photo from a photoset.
265 | *
266 | * This method requires authentication.
267 | *
268 | * @link https://www.flickr.com/services/api/flickr.photosets.removePhoto.html
269 | * @param $photosetId string The ID of the photoset to remove a photo from.
270 | * @param $photoId string The ID of the photo to remove from the set.
271 | * @return bool
272 | */
273 | public function removePhoto($photosetId, $photoId)
274 | {
275 | $params = ["photoset_id" => $photosetId, "photo_id" => $photoId];
276 | $response = $this->flickr->request("flickr.photosets.removePhoto", $params, true);
277 | return isset($response['stat']) && $response['stat'] === 'ok';
278 | }
279 |
280 | /**
281 | * Remove multiple photos from a photoset.
282 | *
283 | * This method requires authentication.
284 | *
285 | * @link https://www.flickr.com/services/api/flickr.photosets.removePhotos.html
286 | * @param $photosetId string The ID of the photoset to remove photos from.
287 | * @param $photoIds string|string[] Array or comma-delimited list of photo IDs to remove from the photoset.
288 | * @return bool
289 | */
290 | public function removePhotos($photosetId, $photoIds)
291 | {
292 | if (is_array($photoIds)) {
293 | $photoIds = implode(",", $photoIds);
294 | }
295 | $params = ['photoset_id' => $photosetId, 'photo_ids' => $photoIds];
296 | $response = $this->flickr->request('flickr.photosets.removePhotos', $params, true);
297 | return isset($response['stat']) && $response['stat'] === 'ok';
298 | }
299 |
300 | /**
301 | * Reorder some or all of the photos in a set.
302 | * This method requires authentication.
303 | * @link https://www.flickr.com/services/api/flickr.photosets.reorderPhotos.html
304 | * @param $photosetId string The ID of the photoset to reorder. The photoset must belong to the calling user.
305 | * @param $photoIds string|string[] Ordered, comma-delimited list or array of photo IDs. Photos that are not in the
306 | * list will keep their original order.
307 | * @return bool
308 | */
309 | public function reorderPhotos($photosetId, $photoIds)
310 | {
311 | if (is_array($photoIds)) {
312 | $photoIds = implode(",", $photoIds);
313 | }
314 | $params = ['photoset_id' => $photosetId, 'photo_ids' => $photoIds];
315 | $response = $this->flickr->request('flickr.photosets.reorderPhotos', $params, true);
316 | return isset($response['stat']) && $response['stat'] === 'ok';
317 | }
318 |
319 | /**
320 | * Set the primary photo of a photoset.
321 | * This method requires authentication.
322 | * @link https://www.flickr.com/services/api/flickr.photosets.setPrimaryPhoto.html
323 | * @param $photosetId string The ID of the photoset to set primary photo to.
324 | * @param $photoId string The ID of the photo to set as primary.
325 | * @return bool
326 | */
327 | public function setPrimaryPhoto($photosetId, $photoId)
328 | {
329 | $response = $this->flickr->request(
330 | 'flickr.photosets.setPrimaryPhoto',
331 | ['photoset_id' => $photosetId, 'photo_id' => $photoId],
332 | true
333 | );
334 | return isset($response['stat']) && $response['stat'] === 'ok';
335 | }
336 | }
337 |
--------------------------------------------------------------------------------