SilverWare\Flickr\API\FlickrAPI
A singleton wrapper providing access to the Flickr API.
- Author: Colin Tucker <colin@praxis.net.au>
- Copyright: 2018 Praxis Interactive
- License: https://opensource.org/licenses/BSD-3-Clause BSD-3-Clause
Synopsis
class FlickrAPI
{
- // members
- private static string $default_endpoint = 'https://api.flickr.com/services/rest';
- private static integer $default_timeout = 10;
- private static string $photo_source_url = 'https://farm%s.staticflickr.com/%s/%s_%s_%s.jpg';
- protected $endpoint;
- protected $timeout;
- protected Client $client;
- protected string $format = 'php_serial';
- // methods
- public void __construct()
- public $this setEndpoint()
- public string getEndpoint()
- public $this setTimeout()
- public integer getTimeout()
- public $this setFormat()
- public string getFormat()
- public string getAPIKey()
- public boolean hasAPIKey()
- public FlickrResponse call()
- public string getPhotoSource()
- public string getPhotoSourceURL()
- protected array buildQuery()
- protected FlickrResponse buildResponse()
- protected array processBody()
Hierarchy
Uses
- SilverStripe\Core\Injector\Injectable
- SilverStripe\Core\Config\Configurable
Members
private
- $default_endpoint
—
string
Defines the default remote API endpoint. - $default_timeout
—
integer
Defines the default API timeout period in seconds. - $photo_source_url
—
string
Defines the photo source URL for retrieving photos from Flickr.
protected
- $client
—
SilverWare\Flickr\API\GuzzleHttp\Client
Holds the client for interacting with the remote API. - $endpoint
—
string
Defines the remote API endpoint. - $format
—
string
Defines the format of the API response. - $timeout
—
integer
Defines the API timeout period in seconds.
Methods
protected
- buildQuery() — Builds the query array for issuing the request.
- buildResponse() — Builds a response object from the given data.
- processBody() — Converts the response body into an array.
public
- __construct() — Constructs the object upon instantiation.
- call() — Issues a request on the API and answers the response.
- getAPIKey() — Answers the API key from site or YAML configuration.
- getEndpoint() — Answers the value of the endpoint attribute.
- getFormat() — Answers the value of the format attribute.
- getPhotoSource() — Answers a photo source URL for the given array of photo data.
- getPhotoSourceURL() — Answers a photo source URL for the given parameters.
- getTimeout() — Answers the value of the timeout attribute.
- hasAPIKey() — Answers true if the receiver has an API key.
- setEndpoint() — Defines the value of the endpoint attribute.
- setFormat() — Defines the value of the format attribute.
- setTimeout() — Defines the value of the timeout attribute.