### Install PhpFlickr via Composer Source: https://github.com/samwilson/phpflickr/blob/main/README.md Use Composer to add the library to your project dependencies. ```bash composer require samwilson/phpflickr ``` ```bash composer require survos/flickr-bundle ``` -------------------------------- ### Apache proxy configuration Source: https://github.com/samwilson/phpflickr/blob/main/README.md Example configuration for an Apache web server to route requests to the Flickr API. ```apache ProxyRequests Off SSLProxyEngine on ProxyPass /flickr https://api.flickr.com/services ProxyPassReverse /flickr https://api.flickr.com/services ``` -------------------------------- ### Initialize PhpFlickr Source: https://github.com/samwilson/phpflickr/blob/main/README.md Create a new PhpFlickr instance after including the Composer autoloader. ```php require_once 'vendor/autoload.php'; $flickr = new \Samwilson\PhpFlickr\PhpFlickr($apiKey, $apiSecret); ``` -------------------------------- ### Configure a proxy server Source: https://github.com/samwilson/phpflickr/blob/main/README.md Sets a base URL for proxying API requests. This is useful for using alternative services or local development proxies. ```php $flickr->setProxyBaseUrl('http://localhost:8181/flickr'); ``` -------------------------------- ### Initialize OAuth Token Storage Source: https://github.com/samwilson/phpflickr/blob/main/README.md Create a storage object to hold authentication tokens, typically using Memory for CLI or Session for web applications. ```php $storage = new \OAuth\Common\Storage\Memory(); $flickr->setOauthStorage($storage); ``` -------------------------------- ### Execute Authenticated Request Source: https://github.com/samwilson/phpflickr/blob/main/README.md Configures the PhpFlickr instance with the storage object and performs an API request. ```php $flickr->setOauthStorage($storage); $recent = $phpFlickr->photos()->getContactsPhotos(); ``` -------------------------------- ### Set a custom user agent Source: https://github.com/samwilson/phpflickr/blob/main/README.md Configures a custom user agent string for API requests, which is recommended for application identification. ```php $flickr->setUserAgent('MyVendor-MyApp/1.0.0'); ``` -------------------------------- ### Retrieve Access Token Source: https://github.com/samwilson/phpflickr/blob/main/README.md Exchange the verifier code for an access token after user authorization. ```php $accessToken = $flickr->retrieveAccessToken($_GET['oauth_verifier'], $_GET['oauth_token']); ``` ```php $verifier = '<9-digit code stripped of hyphens and spaces>'; $accessToken = $flickr->retrieveAccessToken($verifier); ``` -------------------------------- ### Store OAuth1 Access Token Source: https://github.com/samwilson/phpflickr/blob/main/README.md Initializes a memory storage object and populates it with an OAuth1 access token and secret for authenticated requests. ```php // Create storage. $storage = new \OAuth\Common\Storage\Memory(); // Create the access token from the strings you acquired before. $token = new \OAuth\OAuth1\Token\StdOAuth1Token(); $token->setAccessToken($accessToken); $token->setAccessTokenSecret($accessTokenSecret); // Add the token to the storage. $storage->storeAccessToken('Flickr', $token); ``` -------------------------------- ### Generate Authentication URL Source: https://github.com/samwilson/phpflickr/blob/main/README.md Redirect users to the Flickr authorization page with the required permission level. ```php $perm = 'read'; $url = $flickr->getAuthUrl($perm, $callbackUrl); ``` -------------------------------- ### Upload a new photo Source: https://github.com/samwilson/phpflickr/blob/main/README.md Uploads a local image file to Flickr. Requires prior authentication. ```php $flickr->uploader()->upload('/path/to/photo.jpg'); ``` -------------------------------- ### Replace an existing photo Source: https://github.com/samwilson/phpflickr/blob/main/README.md Replaces an existing photo on Flickr with a new file. Metadata cannot be set during this operation. ```php $flickr->uploader()->replace('/path/to/photo.jpg', 44333812150); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.