phpSmug 4.0.0 is here

lildudelildude Registered Users Posts: 70 Big grins
Hey folks.

Sorry about the silence and the delay, but guess what: I've just released phpSmug 4.0.0!!!

Yes, I know, it's been a long time coming, but there hasn't been a need to release another version since I released phpSmug 3.5 back in March 2013, until SmugMug released their newest API, and even then, it was in a long beta. The deprecation of the 1.3.0 API was the kick in the pants I needed to finish off phpSmug 4.0.0 (the PR has been open for over a year :D).

So what's new in phpSmug 4.0.0? I'm glad you asked.

For a start, it's a complete rewrite. Rather than maintaining my own code to perform the HTTP requests, I've switched to using Guzzle. This allows me to concentrate on phpSmug and let someone else concentrate on the finer details of actually talking HTTP. It does however mean phpSmug 4.0.0 and later is not a drop in replacement for phpSmug 3.x.

This has a big advantage in now phpSmug can take advantage of Guzzle's functionality without too much effort. Whilst phpSmug still doesn't have support for asynchronous requests, it shouldn't be too hard to implement it in future as Guzzle already has this functionality. This use of Guzzle also means we can extend phpSmug with relative ease.

phpSmug is now installed using the industry standard method of using Composer. This makes it easier to integrate phpSmug with your projects and pull in all of the dependencies.

And of course, phpSmug is now compatible with SmugMug's vastly superior v2 API. This has got to be one of the best APIs I've worked with. This does unfortunately mean phpSmug 4.0.0 and later is not backwardly compatible with the now deprecated 1.x.x API.

Some other changes include the publication of the test suite. I used to have a test suite before, but due to the embedding of credentials, it was kept private. The switch to Guzzle means I can use Mock objects to test phpSmug without revealing any credentials.

A few lesser changes and improvements:

- phpSmug now uses semantic versioning.
- phpSmug is now licensed under the MIT license.
- Unit tests are run with every push to the GitHub repository.
- PSR-1, PSR-2, and PSR-4 coding standards are implemented and enforced by unit testing.

Other than that, phpSmug is pretty much the same as it was before, though much smaller and cleaner too.

So what's on the cards for phpSmug in future?

Well, I'd like to bring back caching, and in a significantly more intelligent method than before. I'd also like to introduce asynchronous uploads for a start, and then maybe extend that to all requests. If you'd like to help out, please feel free to do so. Check the CONTRIBUTING.md in the repo for more details on how you can help.

If you have any questions or hit any problems, please open an issue in the repo on GitHub and I'll do my best to help you out as soon as I can.

As usual, you can grab the latest release from http://phpsmug.com/download or directly from the repository at https://github.com/lildude/phpSmug.

Comments

  • Martin27Martin27 Registered Users Posts: 3 Beginner grinner
    edited June 11, 2016
    405 Method Not Allowed` response
    Hi,

    Thank you for the great work.

    For code like this:

    $upd_opt = [
    "Title" => "Test Title",
    "Caption" => "Test Caption"
    ];
    echo "$im->Uri\n";
    $client->patch($im->Uri, $upd_opt);

    I get this error message:

    PHP Fatal error: Uncaught exception 'GuzzleHttp\Exception\ClientException' with
    message 'Client error: `PATCH https://api.smugmug.com/api/v2/album/PPMFmW/image
    /WJCLLq5-0` resulted in a `405 Method Not Allowed` response:
    []

    when I try to change the title and caption of an image.
    Is this an authorization issue or have I not quite understood how to use the API?

    Thank you
    Martin
  • lildudelildude Registered Users Posts: 70 Big grins
    edited June 12, 2016
    Hey Martin27

    You're almost there. The problem is the URL you're passing for the image. It needs to be the direct image object which would have a URL of the form `https://api.smugmug.com/api/v2/image/:imagekey` as documented in the API here. The form you are using, as documented here can only be used to remove the image from the album specified.

    Off the top of my head, I think replacing `$im->Uri` with `$im->AlbumImage->Uris->Image->Uri` in your code should do the trick.

    HTH
    — Colin
  • Martin27Martin27 Registered Users Posts: 3 Beginner grinner
    edited June 19, 2016
    It's working
    Hi "lildude",

    Thank you for pointing me in the right direction. It's working now.

    Martin
Sign In or Register to comment.