Skip to content
This repository was archived by the owner on Jan 22, 2025. It is now read-only.

Commit 8616923

Browse files
committed
- Changed API endpoint to use api.zenfolio.com as requested by Zenfolio
- Changed default API version to 1.6 - Added ability to perform ALL API requests over HTTPS (Fixes Ticket #4)
1 parent 4842ea3 commit 8616923

File tree

2 files changed

+55
-25
lines changed

2 files changed

+55
-25
lines changed

README.txt

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
phpZenfolio 1.1 - PHP Wrapper for the Zenfolio API
1+
phpZenfolio 1.2 - PHP Wrapper for the Zenfolio API
22
==================================================
33

44
Written by Colin Seymour
@@ -105,23 +105,23 @@ The constructor takes two arguments, one obligatory and one optional:
105105
application in the event of a problem.
106106

107107
* `APIVer' - Optional
108-
Default: 1.4
108+
Default: 1.6
109109

110-
Use this to set the endpoint you wish to use. The default is 1.4 as this
110+
Use this to set the endpoint you wish to use. The default is 1.6 as this
111111
is the latest endpoint provided by Zenfolio.
112112

113113
As the constructor is a phpZenfolio specific method, it can be instantiated
114114
using one of the following methods:
115115

116116
Arguments as strings:
117117

118-
$f = new phpZenfolio("AppName=My Cool App/1.0 (http://app.com)", "APIVer=1.4");
118+
$f = new phpZenfolio("AppName=My Cool App/1.0 (http://app.com)", "APIVer=1.6");
119119

120120
Arguments as an associative array:
121121

122122
$f = new phpZenfolio( array(
123123
"AppName" => "My Cool App/1.0 (http://app.com)",
124-
"APIVer" => "1.4")
124+
"APIVer" => "1.6")
125125
);
126126

127127
Naturally, you can predefine the array before instantiating the object and just
@@ -369,6 +369,10 @@ Other Notes
369369

370370
Valid arguments are "curl" (default) and "socket".
371371

372+
* phpZenfolio implements Zenfolio objects
373+
(http://www.zenfolio.com/zf/help/api/ref/objects) as arrays. This makes
374+
implementation and usage easier.
375+
372376
* Some people will need to use phpZenfolio from behind a proxy server. You
373377
can use the `setProxy()' method to set the appropriate proxy settings.
374378

@@ -458,6 +462,15 @@ This document is also available online at `http://phpzenfolio.com/docs'.
458462
Change History
459463
==============
460464

465+
* 1.2 - 10 June '12
466+
467+
468+
* Changed API endpoint to use api.zenfolio.com as requested by Zenfolio
469+
470+
* Changed default API version to 1.6
471+
472+
* Added ability to perform ALL API requests over HTTPS (Ticket #4)
473+
461474
* 1.1 - 28 Mar '11
462475

463476

phpZenfolio.php

Lines changed: 37 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* without having to worry about the finer details of the API.
77
*
88
* @author Colin Seymour <[email protected]>
9-
* @version 1.1
9+
* @version 1.2
1010
* @package phpZenfolio
1111
* @license GNU General Public License version 3 {@link http://www.gnu.org/licenses/gpl.html}
1212
* @copyright Copyright (c) 2010 Colin Seymour
@@ -54,27 +54,28 @@ class PhpZenfolioException extends Exception {}
5454
* @package phpZenfolio
5555
**/
5656
class phpZenfolio {
57-
static $version = '1.1';
57+
static $version = '1.2';
5858
private $cacheType = FALSE;
5959
private $cache_expire = 3600;
6060
private $keyring;
6161
private $id;
6262
protected $authToken;
6363
private $adapter = 'curl';
64+
private $secure = FALSE;
6465

6566
/**
66-
* When your database cache table hits this many rows, a cleanup
67-
* will occur to get rid of all of the old rows and cleanup the
68-
* garbage in the table. For most personal apps, 1000 rows should
69-
* be more than enough. If your site gets hit by a lot of traffic
70-
* or you have a lot of disk space to spare, bump this number up.
71-
* You should try to set it high enough that the cleanup only
72-
* happens every once in a while, so this will depend on the growth
73-
* of your table.
74-
*
75-
* @var integer
76-
**/
77-
var $max_cache_rows = 1000;
67+
* When your database cache table hits this many rows, a cleanup
68+
* will occur to get rid of all of the old rows and cleanup the
69+
* garbage in the table. For most personal apps, 1000 rows should
70+
* be more than enough. If your site gets hit by a lot of traffic
71+
* or you have a lot of disk space to spare, bump this number up.
72+
* You should try to set it high enough that the cleanup only
73+
* happens every once in a while, so this will depend on the growth
74+
* of your table.
75+
*
76+
* @var integer
77+
**/
78+
var $max_cache_rows = 1000;
7879

7980
/**
8081
* Constructor to set up a phpZenfolio instance.
@@ -94,13 +95,13 @@ class phpZenfolio {
9495
* in the form "AppName/version (URI)"
9596
* e.g. "My Cool App/1.0 (http://my.url.com)".
9697
* @param string $APIVer (Optional) API endpoint you wish to use.
97-
* Defaults to 1.4
98+
* Defaults to 1.6
9899
* @return void
99100
**/
100101
public function __construct()
101102
{
102103
$args = phpZenfolio::processArgs( func_get_args() );
103-
$this->APIVer = ( array_key_exists( 'APIVer', $args ) ) ? $args['APIVer'] : '1.4';
104+
$this->APIVer = ( array_key_exists( 'APIVer', $args ) ) ? $args['APIVer'] : '1.6';
104105
// Set the Application Name
105106
if ( ! isset( $args['AppName'] ) ) {
106107
throw new PhpZenfolioException( 'Application name missing.', -10001 );
@@ -306,6 +307,7 @@ private function cache( $request, $response )
306307
**/
307308
public function clearCache( $delete = FALSE )
308309
{
310+
$result = TRUE;
309311
if ( $this->cacheType == 'db' ) {
310312
if ( $delete ) {
311313
$result = $this->cache_db->exec( 'DROP TABLE ' . $this->cache_table );
@@ -343,13 +345,13 @@ public function clearCache( $delete = FALSE )
343345
**/
344346
private function request( $command, $args = array() )
345347
{
346-
if ( $command == 'AuthenticatePlain' ) {
348+
if ( $command == 'AuthenticatePlain' || $this->secure === TRUE ) {
347349
$proto = "https";
348350
} else {
349351
$proto = "http";
350352
}
351353

352-
$this->req->setURL( "$proto://www.zenfolio.com/api/{$this->APIVer}/zfapi.asmx" );
354+
$this->req->setURL( "$proto://api.zenfolio.com/api/{$this->APIVer}/zfapi.asmx" );
353355

354356
if ( ! is_null( $this->authToken ) ) {
355357
$this->req->setHeader( 'X-Zenfolio-Token', $this->authToken );
@@ -420,6 +422,21 @@ public function setProxy()
420422
'proxy_auth_scheme' => $this->proxy['auth_scheme'] ) );
421423
}
422424

425+
/**
426+
* Force phpZenfolio to use HTTPS for ALL requests, not just authentication
427+
* requests.
428+
*
429+
* NOTE: This may have an adverse effect on performance if used for ALL requests.
430+
* Use with caution.
431+
*
432+
* @access public
433+
* @return void
434+
**/
435+
public function setSecureOnly()
436+
{
437+
$this->secure = TRUE;
438+
}
439+
423440
/**
424441
* Single login function for all login methods.
425442
*
@@ -526,7 +543,7 @@ public function upload()
526543
$photoset = $this->LoadPhotoSet( $args['PhotoSetId'] );
527544
$UploadUrl = 'http://up.zenfolio.com' . $photoset['UploadUrl'];
528545
} else {
529-
$photoset = ( $this->APIVer == '1.4' ) ? $this->LoadPhotoSet( $args['PhotoSetId'], 'Level1', FALSE ) : $this->LoadPhotoSet( $args['PhotoSetId'] );
546+
$photoset = ( $this->APIVer == '1.4' || $this->APIVer == '1.6' ) ? $this->LoadPhotoSet( $args['PhotoSetId'], 'Level1', FALSE ) : $this->LoadPhotoSet( $args['PhotoSetId'] );
530547
$UploadUrl = $photoset['UploadUrl'];
531548
}
532549
}
@@ -1353,4 +1370,4 @@ private function _unchunk( $body )
13531370
}
13541371
}
13551372

1356-
?>
1373+
?>

0 commit comments

Comments
 (0)