{"id":18123433,"url":"https://github.com/samwilson/phpflickr","last_synced_at":"2025-04-13T06:36:24.586Z","repository":{"id":26050234,"uuid":"69516268","full_name":"samwilson/phpflickr","owner":"samwilson","description":"A PHP wrapper for the Flickr API, including OAuth.","archived":false,"fork":false,"pushed_at":"2024-07-22T23:09:13.000Z","size":407,"stargazers_count":40,"open_issues_count":15,"forks_count":15,"subscribers_count":7,"default_branch":"main","last_synced_at":"2024-09-23T04:19:18.814Z","etag":null,"topics":["flickr","flickr-api","hacktoberfest","libraries","php"],"latest_commit_sha":null,"homepage":"https://packagist.org/packages/samwilson/phpflickr","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"dan-coulter/phpflickr","license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/samwilson.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-09-29T00:52:47.000Z","updated_at":"2024-09-09T00:10:19.000Z","dependencies_parsed_at":"2024-06-18T18:11:39.764Z","dependency_job_id":"4b165aff-682b-457e-939e-89971eab87c0","html_url":"https://github.com/samwilson/phpflickr","commit_stats":{"total_commits":87,"total_committers":19,"mean_commits":4.578947368421052,"dds":"0.32183908045977017","last_synced_commit":"a25e40ade587f51793a51571b9a3c13e129b8534"},"previous_names":[],"tags_count":30,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samwilson%2Fphpflickr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samwilson%2Fphpflickr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samwilson%2Fphpflickr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samwilson%2Fphpflickr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/samwilson","download_url":"https://codeload.github.com/samwilson/phpflickr/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248675300,"owners_count":21143763,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["flickr","flickr-api","hacktoberfest","libraries","php"],"created_at":"2024-11-01T07:09:44.979Z","updated_at":"2025-04-13T06:36:24.546Z","avatar_url":"https://github.com/samwilson.png","language":"PHP","readme":"PhpFlickr\n=========\n\nA PHP wrapper for the Flickr API.\n\nhttps://github.com/samwilson/phpflickr\n\n[![Packagist](https://img.shields.io/packagist/v/samwilson/phpflickr.svg)](https://packagist.org/packages/samwilson/phpflickr)\n\n[![Build status](https://github.com/samwilson/phpflickr/workflows/CI/badge.svg)](https://github.com/samwilson/phpflickr/actions/workflows/ci.yml)\n\nTable of contents:\n\n* [Installation](#installation)\n* [Usage](#usage)\n* [Examples](#examples)\n* [Authentication](#authentication)\n* [Making authenticated requests](#making-authenticated-requests)\n* [Caching](#caching)\n* [Proxy server](#proxy-server)\n* [Uploading](#uploading)\n* [Kudos](#kudos)\n\n## Installation\n\nInstall with [Composer](https://getcomposer.org/):\n\n    composer require samwilson/phpflickr\n\nAlternatively, Symfony developers can install [a bundle](https://github.com/survos/SurvosFlickrBundle):\n\n    composer require survos/flickr-bundle\n\nAfter setting the API key and secret in the environment,\nyou can inject the `FlickrService` into your controller or service,\nrather than instantiating a PhpFlickr object as described below.\n\n## Usage\n\nOnce you've included Composer's autoloader, create a PhpFlickr object.\nFor example:\n\n```php\nrequire_once 'vendor/autoload.php';\n$flickr = new \\Samwilson\\PhpFlickr\\PhpFlickr($apiKey, $apiSecret);\n```\n\nThe constructor takes two arguments:\n\n1. `$apiKey` — This is the API key given to you by Flickr\n   when you [register an app](https://www.flickr.com/services/api/keys/).\n\n2. `$secret` — The API secret is optional because it is only required to\n   make authenticated requests ([see below](#making-authenticated-requests)).\n   It is given to you along with your API key when you register an app.\n\nAll of the API methods have been implemented in phpFlickr.  You can \nsee a full list and documentation here: \n    http://www.flickr.com/services/api/\n\nTo call a method, remove the \"flickr.\" part of the name and replace \nany periods with underscores. For example, instead of \nflickr.photos.search, you would call $f-\u003ephotos_search() or instead \nof flickr.photos.licenses.getInfo, you would call \n$f-\u003ephotos_licenses_getInfo() (yes, it is case sensitive).\n\nAll functions have their arguments implemented in the list order on \ntheir documentation page (a link to which is included with each \nmethod in the phpFlickr clasS). The only exceptions to this are \nphotos_search(), photos_getWithoutGeodata() and \nphotos_getWithoutGeodata() which have so many optional arguments\nthat it's easier for everyone if you just have to pass an \nassociative array of arguments.  See the comment in the \nphotos_search() definition in phpFlickr.php for more information.\n\n## Examples\n\nThere are a few example files in the `examples/` directory.\nTo use these, first copy `examples/config.dist.php` to `examples/config.php`\nand run `php examples/get_auth_token.php` to get the access token.\nAdd this access token to your `examples/config.php`\nand then you can run any of the examples that require authentication\n(note that not all of them do).\n\n## Authentication\n\nThere is only one user authentication method available to the API, and that is OAuth 1.0.\nYou only need to use this if you're performing operations that require it,\nsuch as uploading or accessing private photos.\n\nThis authentication method is somewhat complex,\nbut is secure and allows your users to feel a little safer authenticating to your application.\nYou don't have to ask for their username and password.\n\n☛ *Read more about the [Flickr Authentication API](https://www.flickr.com/services/api/auth.oauth.html).*\n\nWe know how difficult this API looks at first glance,\nso we've tried to make it as transparent as possible for users of phpFlickr.\nWe'll go through all of the steps you'll need to do to use this.\n\nTo have end users authenticate their accounts:\n\n1. Create an object in which to temporarily store the authentication token,\n   and give it to PhpFlickr.\n   This must be an implementation of TokenStorageInterface,\n   and will usually be of type `Session` (for browser-based workflows)\n   or `Memory` (for command-line workflows)\n   — or you can create your own implementation.\n\n   ```php\n   $storage = new \\OAuth\\Common\\Storage\\Memory();\n   $flickr-\u003esetOauthStorage($storage);\n   ```\n\n2. Send your user to a Flickr URL (by redirecting them, or just telling them to click a link),\n   where they'll confirm that they want your application to have the permission you specify\n   (which is either `read`, `write`, or `delete`).\n\n   ```php\n   $perm = 'read';\n   $url = $flickr-\u003egetAuthUrl($perm, $callbackUrl);\n   ```\n\n3. Once the user has authorized your application, they'll\n   either be redirected back to a URL on your site (that you specified as the callback URL above)\n   or be given a nine-digit code that they'll need to copy and paste into your application.\n\n   1. For the browser-based workflow, your callback URL will now have\n      two new query-string parameters: `oauth_token` and `oauth_verifier`.\n   2. For CLI workflow, you'll need to strip anything other than digits from the string that the user gives you\n      (e.g. leading and trailing spaces, and the hyphens in the code).\n\n4. You can now request the final 'access token':\n\n   1. For the browser-based workflow:\n      ```php\n      $accessToken = $flickr-\u003eretrieveAccessToken($_GET['oauth_verifier'], $_GET['oauth_token']);\n      ```\n   2. For the CLI workflow, it's much the same,\n      but because you've still got access to the request token\n      you can leave it out when you run this request:\n      ```php\n      $verifier = '\u003c9-digit code stripped of hyphens and spaces\u003e';\n      $accessToken = $flickr-\u003eretrieveAccessToken($verifier);\n      ```\n\n5. Now you can save the two string parts of the access token\n   (which you can get via\n   the `$accessToken-\u003egetAccessToken()` and `$accessToken-\u003egetAccessTokenSecret()` methods)\n   and use this for future requests.\n   The access token doesn't expire, and must be stored securely\n   (the details of doing that are outside the scope of PhpFlickr).\n\n## Making authenticated requests\n\nOnce you have an access token (see [above](#authentication)),\nyou can store it somewhere secure and use it to make authenticated requests at a later time.\nTo do this, first create a storage object\n(again, as for the initial authentication process, you can choose between different storage types,\nbut for many situations the in-memory storage is sufficient),\nand then store your access token in that object:\n\n```php\n// Create storage.\n$storage = new \\OAuth\\Common\\Storage\\Memory();\n// Create the access token from the strings you acquired before.\n$token = new \\OAuth\\OAuth1\\Token\\StdOAuth1Token();\n$token-\u003esetAccessToken($accessToken);\n$token-\u003esetAccessTokenSecret($accessTokenSecret);\n// Add the token to the storage.\n$storage-\u003estoreAccessToken('Flickr', $token);\n```\n\nNow, you can pass the storage into PhpFlickr, and start making requests:\n\n```php\n$flickr-\u003esetOauthStorage($storage);\n$recent = $phpFlickr-\u003ephotos()-\u003egetContactsPhotos();\n```\n\nSee the [Usage section](#usage) above for more details on the request methods,\nand the `examples/recent_photos.php` file for a working example.\n\n## Caching\n\nPhpFlickr can be used with any PSR-6 compatible cache, such as\n[symfony/cache](https://packagist.org/packages/symfony/cache)\nor [tedivm/stash](https://packagist.org/packages/tedivm/stash).\n\nTo enable caching, pass a configured cache object to `PhpFlickr::setCache($cacheItemPool)`.\n\nAll requests are cached for the same time duration, which by default is 10 minutes.\nThis can be changed with the `PhpFlickr::setCacheDefaultExpiry()`.\n\n## Uploading\n\n### Uploading new photos\n\nUploading is pretty simple. Aside from being authenticated\n(see the [Authentication](#Authentication) section above)\nthe very minimum that you'll have to pass is a path to an image file.\nYou can upload a file as follows:\n\n```php\n$flickr-\u003euploader()-\u003eupload('/path/to/photo.jpg');\n```\n\nThe other upload parameters are documented in the method's docblock.\nOne useful one is the `$async` flag, which permits *asyncronous* uploading,\nwhich means that, rather than uploading the file immediately and before returning,\na 'ticket ID' is returned, with which you can subsequently fetch the upload's status.\nYou can read more about asynchronous uploading\nin [Flickr's API documentation](https://www.flickr.com/services/api/upload.async.html).\n\n### Replacing existing photos\n\nYou can also upload a photo as a replacement to an existing photo.\n\n```php\n$flickr-\u003euploader()-\u003ereplace('/path/to/photo.jpg', 44333812150);\n```\n\nThis method doesn't allow for setting any photo metadata,\nbut you can do the replacement asynchronously\n(in which case a 'ticket ID' will be returned).\n\n## User Agent\n\nIf you are using PhpFlickr in an application, it is a good idea to set a custom user agent.\nThis can be done with the following:\n\n```php\n$flickr-\u003esetUserAgent('MyVendor-MyApp/1.0.0');\n```\n\n## Proxy server\n\nPhpFlickr can be used with a proxy server\nor any service that matches Flickr's API (such as [23 Photo Sharing](http://www.23hq.com)).\nTo use this feature, pass the proxy server's base URL after instantiating a PhpFlickr object.\nFor example:\n\n```php\n$flickr-\u003esetProxyBaseUrl('http://localhost:8181/flickr');\n```\n\nAfter that, all requests will be automatically made through your proxy server.\n\nOne example of configuring such a proxy service, for the Apache webserver, is as follows:\n\n```\nProxyRequests Off\nSSLProxyEngine on\nProxyPass /flickr https://api.flickr.com/services\nProxyPassReverse /flickr https://api.flickr.com/services\n```\n\n## Kudos\n\nThis is a fork of Dan Coulter's original [phpFlickr](https://github.com/dan-coulter/phpflickr)\nlibrary, maintained by Sam Wilson. All the hard work was done by Dan!\n\nThanks also is greatly due to the many other\n[contributors](https://github.com/samwilson/phpflickr/graphs/contributors).\n\nThe [Agateware_Example.JPG](https://commons.wikimedia.org/wiki/File:Agateware_Example.JPG)\nused for the upload examples is [CC-BY-SA](https://creativecommons.org/licenses/by-sa/4.0)\nby User:Anonymouse512, via Wikimedia Commons.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsamwilson%2Fphpflickr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsamwilson%2Fphpflickr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsamwilson%2Fphpflickr/lists"}