Giter Club home page Giter Club logo

phpzenfolio's Introduction

phpZenfolio

Coverage Status Test Status

phpZenfolio is a simple object orientated wrapper for the Zenfolio API, written in PHP.

The intention of this class is to allow PHP application developers quick and easy interaction with the Zenfolio API, without having to worry about the finer details of the API.

Not already a Zenfolio user? Here, have a $5 discount off your first year on me by registering using this code:

4Y5-2ZY-2A8

The development of phpZenfolio takes place in my free time. If you find phpZenfolio useful and found it has saved you a lot of time, I'd really appreciate it if you bought me a coffee or two.

Buy me a Coffee


Note: phpZenfolio 2.0.0 and later is not backwardly compatible with earlier releases.

Requirements

Installation

The recommended method of installing phpZenfolio is using Composer. If you have Composer installed, you can install phpZenfolio and all its dependencies from within your project directory:

$ composer require lildude/phpzenfolio

Alternatively, you can add the following to your project's composer.json:

{
    "require": {
        "lildude/phpzenfolio": "^2.0"
    }
}

.. and then run composer update from within your project directory.

If you don't have Composer installed, you can download it using:

$ curl -s http://getcomposer.org/installer | php

Basic Usage of the phpZenfolio Client

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 (http://app.com)'));
$photoset = $client->LoadPhotoSet(12345, 'Level1');

From the $client object, you have access to all the Zenfolio API methods.

Documentation

See the docs directory or http://phpzenfolio.com for more detailed documentation.

Examples

phpZenfolio comes with four examples to help get you on your way.

  • example-popular.php illustrates how to obtain the 96 most popular galleries and display their title image linking to each individual gallery.
  • example-login.php illustrates how to login and display the images in your first photoset or collection.
  • example-user.php illustrates how to display the first 96 public photos of the specified user's first public photoset found.
  • example-create-photoset.php illustrates how to create a new gallery photoset in the authenticated user's root photoset group, and upload an image to this gallery.

Need Help or Have Questions?

The best way to get help with implementing phpZenfolio into your projects is to open an issue. This allows you to easily search for other issues where others may have asked to the same questions or hit the same problems and if they haven't, your issue will add to the resources available to others at a later date.

Please don't be shy. If you've got a question, problem or are just curious about something, there's a very good chance someone else is too, so go ahead and open an issue and ask.

Contributing

Found a bug or want to make phpZenfolio even better? Please feel free to open a pull request with your changes, but be sure to check out the CONTRIBUTING.md first for some tips and guidelines. No pull request is too small.

Changes

All notable changes to this project are documented in CHANGELOG.md.

License

All code is licensed under the MIT License and all documentation is licensed under the CC BY 4.0 license.

phpzenfolio's People

Contributors

dependabot[bot] avatar lfroidmo avatar lildude avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

phpzenfolio's Issues

Allow guzzlehttp/guzzle version 7

I know these haven't been updated in a while, but if you could add guzzle version 7 support that would be great. We use this and lildude/phpsmug and are trying to update our own guzzle to version 7, but this and lildude/phpsmug are keeping us from doing it, since the composer.json file here and at lildude/phpsmug only have 6 listed, and not 6 | 7.

Not able to download the Zenfolio Original images

Hi,

I am using phpZenfolio 1.3 and I am able to authenticate and getting resized images by calling corresponding functions.
But I am NOT able to download the Original images and instead I am getting the image with content as 'Content Protected by Owner'.

Here is the process which i followed.

I followed the below link and got the knowledge how to download the Original images through Zenfolio PHP wrapper.
https://www.zenfolio.com/zf/help/api/guide/download

Code snippet:

  1. main.php

function checkZenfolioOriginalImageDownload() {

    $url = getImagesOnToken(TOKEN, ID, 1);       
    $fileName = WEDDING_IMG_PATH_MAIN.'test/originalImage1.jpg';
    $contents = file_get_contents($url);
    $fp = fopen($fileName, 'w+');
    fwrite($fp, $contents);
    fclose($fp);
    system('chmod -R 777 '.$fileName);
    exit;


}
  1. getImageUrl.php

function getImagesOnToken($checkAuth, $galId, $photoCount) {
require_once '../webroot/phpZenfolio.php';
$appName = 'testApp.zenfolio.com';
$f = new phpZenfolio("AppName={$appName}");
try {

        $f->setAuthToken($checkAuth);  // $checkAuth - password token           
        $photos = $f->LoadPhotoSetPhotos($galId, 0, $photoCount);

        $photoIdArray = array();
        foreach($photos as $photoItem) {
            $photoIdArray[] = $photoItem['Id'];
        }
        $originalKey = $f->GetDownloadOriginalKey($photoIdArray, $checkAuth); // $checkAuth - password token

        $originalImageUrl = phpZenfolio::imageUrl($photos, 1, $originalKey, 'original');
        return originalImageUrl;

     } catch (Exception $e) {
        $r['status'] = false;
        $r['error'] = $e->getMessage();
        echo json_encode($r);
        exit;
        echo "{$e->getMessage()} (Error Code: {$e->getCode()})";
    }

}

  1. phpZenfolio.php (version 1.3)

    public static function imageUrl( $photo, $size, $originalKey, $showType ) {

         if ($showType == 'show') {
             return "http://{$photo['UrlHost']}/{$photo['UrlCore']}-{$size}.jpg?sn={$photo['Sequence']}&tk={$photo['UrlToken']}";
         } else {
             // Returning original image url
             return $photo['OriginalUrl']."?key=".$originalKey;
         }
    

    }

RESULT : Original url

http://nagarajan.zenfolio.com/img/s11/v28/p2129545206.jpg?key=nTaE0lylIh-YUj_Lv-mA_NNxgjrExcqwgBzYgzG--VboMUEKSBuchkfx18M2brh5K0FmrlZtzReIi7e-V_9k0g==

The issue is that the above URL displaying the original image on the browser BUT the image not getting downloaded into the system as per the code (1. main.php), instead its displaying "Content Protected by Owner".

I hope that you can understand the process and issues occurred. Please help me to sorted this out.

Thank you.

Error with LoadGroupHierarchy and LoadPublicProfile (possibly others)

I wasn't sure whether to open a new issue, or post to the closed issue #12 as it's the same problem. Using the examples, I am getting the E_NOSUCHOBJECT error when hitting the LoadGroupHierarchy method (I've also tried with LoadPublicProfile, and get the same exception. I'm guessing some others would as well, but those are the two I've tried.)

I am definitely using the username and not email, and it appears to be logging in alright, as I am getting an authToken. Also, I am able to access images and upload an image to a photoset (so not all methods are affected.)

I tried contacting Zenfolio support, and they mentioned I should contact you. Their exact response was:

Thank you for your patience while this was sent over for further investigation.

You mention that you are interfacing with the Zenfolio API through the third party tool, phpZenfolio Wrapper. We would suggest you contact the developer of that tool to see if he is working on any known issues with the LoadGroupHierarchy and LoadPublicProfile access via his tool.

If there are any issues, he will work with our engineers to get them fixed.

Thanks,

Zack | Zenfolio Customer Support
Visit our Online Support Center

Below is the contents of my modified example-login.php file. The only difference is I have added the appname, username, and password (removed from the pasted code.) I have also added some debugging commands to isolate where the problem was, and it breaks before the third var_dump (during the call to LoadGroupHierarchy.) Results can be seen here: [REDACTED].

/**
 * Copyright (c) 2010 Colin Seymour
 *
 * This file is part of phpZenfolio.
 *
 * phpZenfolio is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * phpZenfolio is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with phpZenfolio.  If not, see <http://www.gnu.org/licenses/>.
 */
?>
<html>
<head>
    <title>phpZenfolio Login Example</title>
    <style type="text/css">
        body { background-color: #fff; color: #444; }
        div { width: 600px; margin: 0 auto; text-align: center; }
        img { border: 0;}
    </style>
</head>
<body>
    <div>
        <a href="http://phpzenfolio.com"><img src="phpZenfolio-logo.png" /></a>
        <h2>phpZenfolio Login Example</h2>
<?php
/* Last updated with phpZenfolio 1.0
 *
 * This example file shows you how to login and display all the images of the your
 * first photoset or collection, regardless of whether it's public or not.
 *
 * You'll need to set the following:
 * - $appname to your application name, version and URL
 * - $username to your Zenfolio username
 * - $password to your user's password
 *
 * The application name and version is required, but there is no required format.
 * See the README.txt for a suggested format.
 *
 * You can see this example in action at http://phpzenfolio.com/examples/
 */
require_once("../phpZenfolio.php");

$appname = 'My Cool App/1.0 (http://my.url.com)';
$username = 'webmstreagleeye';
$password = '[redacted]';


try {
    $f = new phpZenfolio("AppName={$appname}", "APIVer=1.8");
echo("<h2>Initialized Zenfolio object:</h2><p>");
var_dump($f);
echo("</p><h3>Logging in...</h3>");
    // Login. As Plaintext is not passed, the challenge-response authentication method is used.
    $f->login("Username={$username}", "Password={$password}");
echo("<h2>Logged-in Zenfolio object:</h2><p>");
var_dump($f);
echo("</p><h3>Loading hierarchy...</h3>");
    // Load the User's hierachy
    $h = $f->LoadGroupHierarchy($username);
echo("<h2>Group Hierarchy:</h2><p>");
var_dump($h);
echo("</p>");
    // Load the photos for the first set/collection
    $photos = $f->LoadPhotoSetPhotos($h['Elements'][0]['Id'], 0, $h['Elements'][0]['PhotoCount']);
    // Display the 60x60 cropped thumbnails and link to the image page for each image in the first gallery/collection.
    foreach ($photos as $photo) {
        echo '<a href="',$photo['PageUrl'],'"><img src="',phpZenfolio::imageUrl($photo, 1),'" title="',$photo['Title'],'" alt="',$photo['Id'],'" /></a>';
    }
}
catch (Exception $e) {
    echo "{$e->getMessage()} (Error Code: {$e->getCode()})";
}
?>
    </div>
</body>
</html>

Please update documentation and any calls to the API to call API version 1.8

Thanks for your reply to the Tweet from Zenfolio. This is the issue which they had contacted you about.

Zenfolio has deprecated API 1.6, so any calls to that API will error out.

I noticed on your documentation at: http://phpzenfolio.com/docs/

APIVer - Optional
Default: 1.6

Use this to set the endpoint you wish to use. The default is 1.6 as this
is the latest endpoint provided by Zenfolio.

If there are any example code snippets which use this API version call, they will fail also.

Thanks.

Still supported?

Is this project still supported? I see there haven't been any updates in several years and I keep getting E_DEPRECATEDVERSION messages when I issue some commands, like CreatePhotoSet, upload, CreateGroup, etc.

Zenfolio API Error for method LoadPhotoSetPhotos

Hi,

There are 3 groups(albums) in my Zenfolio account called Homepage, Portfolio and Client Galleries.
Here 'Client Galleries' group having 2 more groups called 2015 and 2016 but both are Empty.

API : phpZenfolio.php 1.3
->LoadGroupHierarchy($username);
Its loaded all the groups available(Homepage, Portfolio and Client Galleries) from Zenfolio account after Successful Authentication.
->LoadPhotoSetPhotos($albumId, 0, $imagesCount); here $imageCount = 0; (No images for that group)
When i try to call this method for 'Client Galeries>>2015 OR Client Galeries>>2016' groups, its returning the following error.
Zenfolio API Error for method LoadPhotoSetPhotos: E_NOSUCHOBJECT
But its working fine and returning the right images for Other groups "Homepage, Portfolio" which are having images.
So, I request you to provide the solution for this issue.

Thank you,
Nagarajan

Zenfolio moving to HTTPS-only

Hello,

Over the past 18 months, Zenfolio has been working to strengthen and improve its infrastructure to provide a more reliable and secure platform for all of our photographers, photographers’ clients, partners, and developers. While performing these improvements, we are transitioning the Zenfolio API to an HTTPS-only environment. Due to recent infrastructure changes, unencrypted HTTP calls may not work as expected, as the typical reason an API call may fail is that HTTP is being redirected to HTTPS. Please note that any issues that may arise from an unencrypted HTTP call may be resolved by updating to HTTPS-only API calls. We apologize for any inconvenience this may cause and we look forward to continuing a partnership with you.

For best performance, please review your code to ensure only HTTPS calls are being made to the Zenolio API.

Thanks,
Chris Gauthier
Sr. Manager, Data Center and IT Operations
Zenfolio, Inc.

Get images url

Hello,
Need a help in Zenfolio. Need to get the image url.
For example
http://www.zenfolio.com/cdn/pub/6rhr1mgujado/0/null/m/kd9huj2ukkmjnzvx2t6y/s7/v165/p2381501363-3.jpg?ts=6VH&tk=33XfJjt33Doahj8eJht_fzXm2gP5K0kMoog0BqgEvkE=

http://www.zenfolio.com/cdn/pub/6rhr1mgujado/0/null/m/nsfnersapkgxix9uexzy/s6/v144/p2412163861-2.jpg?ts=6VH&tk=r1Mq964lmETFBXJ62P7lsMhZ0kWoROPAXxRsMpb-Gf0=

in the above url from ‘p2381501363-3.jpg’ and p2412163861-2.jpg, photo id is ‘2381501363’ and ‘2412163861’. But how the other part of url is created? Do you have any documentation of how the image url is created.

I will be helpfull, if you let me know.

How to Check whether the User Token is Valid or Not.

Hi,

This is Nagarajan,
I am using the phpZenfolio.php 1.3.

I am doing the Authentication by calling the function ->login($username, $password) and keeping the username and generated Token in the Database.

If the user logins at second time, I will fetch the username and Token from our database. And will call the corresponding functions ->setAuthToken($dbToken) and ->LoadGroupHierarchy($dbUsername) for getting the Zenfolio albums. Here I am not checking whether the existing Token is Valid or not. But This is necessary to check here.

I have referred the document but I couldn't find it. I request you to provide the specific function for checking whether the existing token is valid or not OR Authentication by using Token alone.

Thank you,
Nagarajan

Uncaught exception 'PhpZenfolioException' with message 'File doesn't exist:

Hi, I am using the upload method , but it returns an error.

I will leave a piece of code where I am using this method as well as the error
returned in the browser.

Here's the code I'm using:

error_reporting(E_ALL);
ini_set('display_errors', 1);

require_once("phpZenfolio.php");
$f = new phpZenfolio(array("AppName"=>"gbnuevo", "APIVer" => "1.6"));

$f->login("Username=_", "Password=_");

$news = $f->upload("PhotoSetId=404731699",
"File=/images/Tomorrowland_2014.jpg");

echo json_encode($news);

This is the error returned in the browser:

Fatal error: Uncaught exception 'PhpZenfolioException' with message 'File
doesn't exist: /images/Tomorrowland_2014.jpg' in
/Library/WebServer/Documents/pruebaZenfolio/phpZenfolio.php:512 Stack trace:
#0 /Library/WebServer/Documents/pruebaZenfolio/zenPrueba.php(10):

phpZenfolio->upload('PhotoSetId=4047...', 'File=/images/To...') #1 {main}
thrown in /Library/WebServer/Documents/pruebaZenfolio/phpZenfolio.php on line
512

they could tell me this error refers to ?

obviously the images folder and image exist in the project .

access specifier implementation

Hi

I have configured zenfolio php wrapper class to create folder and upload files in it. It's working properly.

I have used the "CreatePhotoSet" method with zenfolio object to create folder.

Now i want to add the Access control on the created folder say private, public etc.

I have gone through the doc and as per it have to use "AccessUpdater" method with zenfoilio object, but I am unable to do this.

Please correct if i am doing any mistake or missing any stuff.

php sample code will help me lot.

Thanks In ADV.

Raw file upload

Hi,

  I am using phpzenfolio api for uploading raw files to zenfolio.
  file format like dng work perfectly but getting below error for .svg and .eip format

Client error: POST http://up.zenfolio.com/richardmourant/p578733668/raw.ushx?filename=demo-property-Raw_1.svg resulted in a 400 Bad Request response: Bad Request (Error Code: 400)

Any suggestion will be really helpfull

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.