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

Commit 24e7ff5

Browse files
committed
Wrap code in codeblocks
1 parent 2060b18 commit 24e7ff5

File tree

1 file changed

+98
-56
lines changed

1 file changed

+98
-56
lines changed

README.md

Lines changed: 98 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,20 @@ To make things easy for developers, phpZenfolio also provides several of it's ow
4545

4646
To use phpZenfolio, all you have to do is include the file in your PHP scripts and create an instance. For example:
4747

48-
require_once("phpZenfolio/phpZenfolio.php");
49-
$f = new phpZenfolio(... arguments go here ...);
48+
```
49+
require_once("phpZenfolio/phpZenfolio.php");
50+
$f = new phpZenfolio(... arguments go here ...);
51+
```
5052

5153
The constructor takes two arguments, one obligatory and one optional:
5254

5355
* `AppName` - Required
5456

5557
This is the name, version and URL of the application you have built using phpZenfolio. There is no required format, but something like:
5658

57-
"My Cool App/1.0 (http://my.url.com)"
59+
```
60+
"My Cool App/1.0 (http://my.url.com)"
61+
```
5862

5963
... would be very useful and will allow Zenfolio to identify your application in the event of a problem.
6064

@@ -65,45 +69,55 @@ The constructor takes two arguments, one obligatory and one optional:
6569

6670
As the constructor is a phpZenfolio specific method, it can be instantiated using one of the following methods:
6771

68-
Arguments as strings:
72+
* Arguments as strings:
6973

70-
$f = new phpZenfolio("AppName=My Cool App/1.0 (http://app.com)", "APIVer=1.8");
74+
```
75+
$f = new phpZenfolio("AppName=My Cool App/1.0 (http://app.com)", "APIVer=1.8");
76+
```
7177

72-
Arguments as an associative array:
78+
* Arguments as an associative array:
7379

74-
$f = new phpZenfolio( array(
75-
"AppName" => "My Cool App/1.0 (http://app.com)",
76-
"APIVer" => "1.8")
77-
);
80+
```
81+
$f = new phpZenfolio(array(
82+
"AppName" => "My Cool App/1.0 (http://app.com)",
83+
"APIVer" => "1.8")
84+
);
85+
```
7886

7987
Naturally, you can predefine the array before instantiating the object and just pass the array variable.
8088

8189
With the instance instantiated, you can now interact with the Zenfolio API using Zenfolio's native methods exactly as they're documented. Arguments to all Zenfolio native methods must be provided in the order they are documented in the API documentation. For example, use the following to get all recent sets that are of the PhotoSetType 'Gallery':
8290

83-
$f->GetRecentSets('Gallery', 0, 3);
91+
```
92+
$f->GetRecentSets('Gallery', 0, 3);
93+
```
8494

8595
Note the method's capitalisation and the arguments, these are as they are documented in the [`GetRecentSets()`](http://www.zenfolio.com/zf/help/api/ref/methods/getrecentsets) method documentation.
8696

8797
Some of the Zenfolio API methods, like `CreatePhotoSet()`, require an object to be passed as one of the arguments. The object can be passed either as an associative array:
8898

89-
$photoSetUpdater = array(
90-
"Title" => "PhotoSet Title",
91-
"Caption" => "PhotoSet Caption via API",
92-
"Keywords" => array("Keyword1", "keyword2"),
93-
"Categories" => array(),
94-
"CustomReference" => "testing/test-photoset"
95-
);
96-
$f->CreatePhotoSet(12345, 'Gallery', $photoSetUpdater );
99+
```
100+
$photoSetUpdater = array(
101+
"Title" => "PhotoSet Title",
102+
"Caption" => "PhotoSet Caption via API",
103+
"Keywords" => array("Keyword1", "keyword2"),
104+
"Categories" => array(),
105+
"CustomReference" => "testing/test-photoset"
106+
);
107+
$f->CreatePhotoSet(12345, 'Gallery', $photoSetUpdater);
108+
```
97109

98110
... or as a standard class object:
99111

100-
$photoSetUpdater = new stdClass();
101-
$photoSetUpdater->Title = "PhotoSet Title";
102-
$photoSetUpdater->Caption = "PhotoSet Caption via Object"|;
103-
$photoSetUpdater->Keywords = array("Keyword1", "keyword2");
104-
$photoSetUpdater->Categories = array();
105-
$photoSetUpdater->CustomReference = "testing/test-photoset";
106-
$f->CreatePhotoSet(12345, 'Gallery', $photoSetUpdater );
112+
```
113+
$photoSetUpdater = new stdClass();
114+
$photoSetUpdater->Title = "PhotoSet Title";
115+
$photoSetUpdater->Caption = "PhotoSet Caption via Object";
116+
$photoSetUpdater->Keywords = array("Keyword1", "keyword2");
117+
$photoSetUpdater->Categories = array();
118+
$photoSetUpdater->CustomReference = "testing/test-photoset";
119+
$f->CreatePhotoSet(12345, 'Gallery', $photoSetUpdater);
120+
```
107121

108122
All data returned by the method call is returned as the API documents it with the exception being objects are actually returned as arrays by phpZenfolio. In the event of an error, phpZenfolio will throw one of two exceptions: `PhpZenfolioException` in the event of a problem detected by phpZenfolio or `HttpRequestException` in the event of a problem detected by the code used to communicate with the API. Your application will need to catch these exceptions.
109123

@@ -118,11 +132,15 @@ phpZenfolio allows you to use the API methods as documented, however to make thi
118132

119133
* Challenge-Response (default):
120134

121-
$f->login("Username=<username>", "Password=<password>");
135+
```
136+
$f->login("Username=<username>", "Password=<password>");
137+
```
122138

123139
* Plain-Text:
124140

125-
$f->login("Username=<username>", "Password=<password>", "Plaintext=TRUE");
141+
```
142+
$f->login("Username=<username>", "Password=<password>", "Plaintext=TRUE");
143+
```
126144

127145
The Plain-Text method uses HTTPS/SSL for the authentication step to ensure your username and password are encrypted when transmitted to Zenfolio.
128146

@@ -147,7 +165,9 @@ The `enableCache()` method takes 4 arguments:
147165

148166
This a PEAR::MDB2 DSN connection string, for example:
149167

150-
mysql://user:password@server/database
168+
```
169+
mysql://user:password@server/database
170+
```
151171

152172
phpZenfolio uses the MDB2 PEAR module to interact with the database if you use database based caching. phpZenfolio does *NOT* supply the necessary PEAR modules. If you with to use a database for caching, you will need to download and install PEAR, the MDB2 PEAR module and the corresponding database driver yourself. See [MDB2 Manual](http://pear.php.net/manual/en/package.database.mdb2.intro.php) for details.
153173

@@ -161,9 +181,11 @@ You may not want to allow the world to view the files that are created during ca
161181

162182
In Apache, you can specify this in the configuration files or in a .htaccess file with the following directives:
163183

164-
<FilesMatch "\.cache$">
165-
Deny from all
166-
</FilesMatch>
184+
```
185+
<FilesMatch "\.cache$">
186+
Deny from all
187+
</FilesMatch>
188+
```
167189

168190
Alternatively, you can specify a directory that is outside of the web server's document root.
169191

@@ -183,11 +205,15 @@ Each of the caching methods can be enabled as follows:
183205

184206
* Filesystem based cache:
185207

186-
$f->enableCache("type=fs", "cache_dir=/tmp", "cache_expire=86400" );
208+
```
209+
$f->enableCache("type=fs", "cache_dir=/tmp", "cache_expire=86400");
210+
```
187211

188212
* Database based cache:
189213

190-
$f->enableCache("type=db", "dsn=mysql://USERNAME:PASSWORD_database", "cache_expire=86400");
214+
```
215+
$f->enableCache("type=db", "dsn=mysql://USERNAME:PASSWORD_database", "cache_expire=86400");
216+
```
191217

192218
If you have caching enabled, and you make changes, it's a good idea to call `clearCache()` to refresh the cache so your changes are reflected immediately.
193219

@@ -204,19 +230,25 @@ Uploading is very easy. You can either upload an image from your local system u
204230

205231
* Upload using the PhotoSetId:
206232

207-
$f->upload("PhotoSetId=123456", "File=/path/to/image.jpg");
233+
```
234+
$f->upload("PhotoSetId=123456", "File=/path/to/image.jpg");
235+
```
208236
209237
* Upload using the UploadUrl:
210238
211-
$f->upload("UploadUrl=http://up.zenfolio.com/....",
212-
"File=/path/to/image.jpg");
239+
```
240+
$f->upload("UploadUrl=http://up.zenfolio.com/....",
241+
"File=/path/to/image.jpg");
242+
```
213243
214244
At this time, the only supported options you can pass at the time of uploading are a `filename` the `modified` parameter which takes a RFC2822 formatted date string...
215245
216-
$f->upload("PhotoSetId=123456",
217-
"File=/path/to/image.jpg",
218-
"filename=newfilename.jpg",
219-
"modified=Thu, 14 Jan 2010 13:08:07 +0200");
246+
```
247+
$f->upload("PhotoSetId=123456",
248+
"File=/path/to/image.jpg",
249+
"filename=newfilename.jpg",
250+
"modified=Thu, 14 Jan 2010 13:08:07 +0200");
251+
```
220252
221253
If you don't specify a filename, the original filename is used.
222254
@@ -225,7 +257,9 @@ Uploading is very easy. You can either upload an image from your local system u
225257
226258
Uploading to Zenfolio using a URL is done purely by the Zenfolio `CreatePhotoFromUrl()` API method:
227259
228-
$f->CreatePhotoFromUrl( 12344, "http://www.example.com/images/image.jpg", null );
260+
```
261+
$f->CreatePhotoFromUrl(12344, "http://www.example.com/images/image.jpg", null);
262+
```
229263
230264
You can find full details on the options this method accepts in the [CreatePhotoFromUrl](http://www.zenfolio.com/zf/help/api/ref/methods/createphotofromurl) method documentation.
231265
@@ -246,8 +280,10 @@ In order to replace a photo, you will need to upload a new photo and then replac
246280
use of sockets, you can do so using the phpZenfolio supplied
247281
`setAdapter()` right after instantiating your instance:
248282
249-
$f = new phpZenfolio("AppName=<value>");
250-
$f->setAdapter("socket");
283+
```
284+
$f = new phpZenfolio("AppName=<value>");
285+
$f->setAdapter("socket");
286+
```
251287
252288
Valid arguments are "curl" (default) and "socket".
253289
@@ -257,32 +293,38 @@ In order to replace a photo, you will need to upload a new photo and then replac
257293
258294
For example:
259295
260-
$f = new phpZenfolio("AppName=<value>");
261-
$f->setProxy("server=<proxy_server>", "port=<value>");
296+
```
297+
$f = new phpZenfolio("AppName=<value>");
298+
$f->setProxy("server=<proxy_server>", "port=<value>");
299+
```
262300
263301
All your calls will then pass through the specified proxy on the specified port.
264302
265303
If your proxy server requires a username and password, then add those options to the `setProxy()` method arguments too.
266304
267305
For example:
268306
269-
$f = new phpZenfolio("AppName=<value>");
270-
$f->setProxy("server=<proxy_server>",
271-
"port=<value>",
272-
"user=<proxy_username>",
273-
"password=<proxy_password>");
307+
```
308+
$f = new phpZenfolio("AppName=<value>");
309+
$f->setProxy("server=<proxy_server>",
310+
"port=<value>",
311+
"user=<proxy_username>",
312+
"password=<proxy_password>");
313+
```
274314
275315
Note: Proxy support is currently only available when using the default "curl" adapter.
276316
277317
* To make it easy to obtain the direct URL to an image, phpZenfolio supplies a `imageURL()` method that takes the Photo object as returned by methods like `LoadPhoto()` and `LoadPhotoSetPhotos()` and an integer for the desired photo size where the integer is one of those documented at http://www.zenfolio.com/zf/help/api/guide/download .
278318
279319
For example:
280320
281-
$f = new phpZenfolio("AppName=<value>");
282-
$photos = $f->LoadPhotoSetPhotos(<photosetID>, <startingIndex>, <numberOfPhotos>);
283-
foreach ($photos as $photo) {
284-
echo '<img src="',phpZenfolio::imageUrl($photo, 1),'" />';
285-
}
321+
```
322+
$f = new phpZenfolio("AppName=<value>");
323+
$photos = $f->LoadPhotoSetPhotos(<photosetID>, <startingIndex>, <numberOfPhotos>);
324+
foreach ($photos as $photo) {
325+
echo '<img src="',phpZenfolio::imageUrl($photo, 1),'" />';
326+
}
327+
```
286328
287329
* If phpZenfolio encounters an error, or Zenfolio returns a "failure" response, an exception will be thrown and your application will stop executing. If there is a problem with communicating with the endpoint, a HttpRequestException will be thrown. If an error is detected elsewhere, a PhpZenfolioException will be thrown.
288330

0 commit comments

Comments
 (0)