phpZenfolio follows the PSR-1, PSR-2 and PSR-4 conventions, which means you can easily use Composer's autoloading to integrate phpZenfolio into your projects.
<?php
// This file is generated by Composer
require_once 'vendor/autoload.php';
$client = new phpZenfolio\Client('My Cool App/1.0 (https://app.com)'));
$photoset = $client->LoadPhotoSet(12345, 'Level1');From the $client object, you can access all the Zenfolio API methods.
The phpZenfolio\Client() constructor takes two arguments:
-
AppName- Required.The name, version and URL of the application you have built using the phpZenfolio. There is no required format, but something like
My Cool App/1.0 (https://my.url.com)would be very useful. -
An array of options - Optional.
The options you pass here become the default options applied to all requests by default, unless explicitly overwritten elsewhere, and can be made up of any combination of the following options:
-
api_version- (string) The API version you wish to use. This defaults to1.8as this is the only version of the API this version of phpZenfolio is compatible with. This is really only for "future proofing". -
proxy- (string) Configure all phpZenfolio requests to pass through a proxy. See the "Access Zenfolio via a Proxy" section for more details. -
debug- (boolean) Enables Guzzle's debug output. This is only really useful during development.
-
Additionally, you can pass any Guzzle request option though debug and proxy are probably the only options you may want to set.
Once you've instantiated an instance of the phpZenfolio\Client, you can use any of the Zenfolio methods, exactly as they're documented, to interact with the API. This means you will need to pass the arguments in the order, case and form that Zenfolio expects.
Remember: ALL function names and arguments ARE case sensitive and the order of arguments is important.
Note: phpZenfolio does not currently support asynchronous requests, though as we now rely on Guzzle, this shouldn't be too hard to implement in future (PRs welcome 😉).
Some of the Zenfolio API methods, like CreatePhotoSet(), or UpdatePhoto() require an Updater object to be passed as one of the arguments. phpZenfolio allows you to pass the object either as an associative array:
<?php
$photoSetUpdater = array(
'Title' => 'PhotoSet Title',
'Caption' => 'PhotoSet Caption via API',
'Keywords' => array('Keyword1', 'keyword2'),
'Categories' => array(),
'CustomReference' => 'testing/test-photoset'
);
$client->CreatePhotoSet(12345, 'Gallery', $photoSetUpdater);... or as a standard class object:
<?php
$photoSetUpdater = new stdClass();
$photoSetUpdater->Title = 'PhotoSet Title';
$photoSetUpdater->Caption = 'PhotoSet Caption via Object';
$photoSetUpdater->Keywords = array('Keyword1', 'keyword2');
$photoSetUpdater->Categories = array();
$photoSetUpdater->CustomReference = 'testing/test-photoset';
$client->CreatePhotoSet(12345, 'Gallery', $photoSetUpdater);All data returned by the method call is returned as the API documents it.