Finally, after 7 months of slow, but steady development, I'm happy to announce phpSmug 2.0 is now available for download.
It's been a long time coming as there has only been one bug reported in the last release, and it wasn't a major issue, and I've been working on consolidating the code to make it more uniform and a lot easier to manage and maintain.
What's New?
First things first, I have to issue a warning:
phpSmug 2.0 is NOT a drop in replacement for phpSmug 1.0.x of 1.1.x.
Please ensure you read this post, which is also documented in the README and the documentation, for details on how phpSmug 2.x now functions.
Right, now we've got that out of the way, lets get to the nitty gritty.
For those who've used phpSmug before, things have changed with phpSmug 2.0 and hopefully it's for the good and won't be too much trouble to adapt your applications for.
If you've not used phpSmug before, you can skip the rest of this post as it won't mean much to you.
- Method Arguments
The general functionality is the same, however the method of passing arguments to methods has changed.
Now when you pass arguments to a method, you need to pass them either as a series of strings, for example:
$f->images_getInfo("ImageID=<value>", "ImageKey=<value>");… or as an array …$f->images_getInfo(array("ImageID" => "<value>", "ImageKey" => "<value>"));This is a deliberate design decision to keep things consistent and is actually due to work I've done to ease the development and maintenance of phpSmug. You'll see phpSmug 2.0 is considerably smaller than previous versions. This is because phpSmug now uses PHP 5's__call()method to dynamically create the API calls for methods that are not explicitly declared. As a result of this, phpSmug 2.0 and later will definitely NOT work with PHP4. It also has the added bonus in that you no longer need to have empty arguments in your method calls: you only need to pass what's required or what you need. - SmugMug API Endpoint Compatibility
phpSmug 2.0 defaults to using the only stable endpoint provided by SmugMug: the 1.2.0 endpoint. However, it is fully functional with the later endpoint revisions, unless otherwise documented on the "Current Issues" page.
To use a later version of the endpoint, just set the version when instantiating the instance using
APIver. - All
smugmug.login.*Methods Handled by a Singlelogin()Method To simplfy things even further, I've consolidated all thesmugmug.login.*API methods into a singlelogin()method. phpSmug will determine which API method you wish to use from the arguments passed when calling the method. If not arguments are passed, phpSmug will login anonymously. - phpSmug now throws exceptions on error In order to take full advantage of PHP5 functionality and make phpSmug behave more like a proper PHP class, I've removed the "die_on_error" functionality and instead turned to using exceptions. It's up to you as the application developer to catch the exceptions and turn it into something useful for your users. All the examples supplied with phpSmug now catch the exceptions. The only exception to this is caching. If there is a problem creating the cache, phpSmug will just error and continue without using any caching. I didn't think it worth stopping the world due to a caching issue.
So, go on, get downloading and if you encounter any problems, please leave a comment on this post.
Buy Me A Beer
SmugMug Discount
LATEST ENTRIES
phpSmug Users
If you're using phpSmug and wish to let the world know, drop me a line and I'll add a link and short description here
31 October 2008 @ 18:07
Hi Colin,
Congrats on the new version. Eagerly downloading to use the same on my current app. Keep up the good work.
7 November 2008 @ 07:21
Colin,
Thank you for phpSmug 2.0! Awesome job and it's saving me tons of time writing a new app for smugmug. I came across a small BUG that I wanted to let you know about:
phpSmug.php (line 350) new Exception is thrown with the fallowing call:
throw new Exception("SmugMug API Error for method {$command}: {$this->error_msg}", $this->parsed_response['code']);
the error code doesn't get passed down to Exception for some reason ... I can get to it from "$this->error_code" which you set few lines above:
$this->error_code = $this->parsed_response['code'];
so perhaps if you changed the "throw new Exception" to:
throw new Exception("SmugMug API Error for method {$command}: {$this->error_msg}", $this->error_code);
it might work ... in fact I'll try it out now, but I wanted to run it by you to see if there was maybe a reason you did it this way.
Regards,
-MVE
7 November 2008 @ 07:27
Just to confirm -- this works:
throw new Exception("SmugMug API Error for method {$command}: {$this->error_msg}", $this->error_code);
I can now get to the error code via "$e->getCode()"
Regards,
- MVE
7 November 2008 @ 15:33
Nice one. Thanks MVE. I can't think why I didn't do that in the first place. I'll document it and get testing.
7 November 2008 @ 15:47
MVE: I've verified your findings. Def a bug. I've fixed it in my copy of the code and will roll out an update later today.
7 November 2008 @ 16:51
I've rectified this and released rev 2.0.1.
Comments on this post will now be closed. Please ensure you report any issues against 2.0.1