Implementing Getty Images API SDK – PHP

I have been implementing Getty Images API SDK and for my infinite luck into wordpress theme. It’s no secrete that PHP is my least favourite language. And of course there were these obscure errors, I love so much, during the implementation. So here is how I get the shit done.

Build

I’m not frequent user of PHP and it was surprise for me when I get to  Getty Images API SDK – PHP and found out, that I have to use some kind of package manager to install it. So went the other way and builded it from source. All you have to do is just download or clone it. And run

./build.sh

If you get error run

php --ini

and locate php.ini file. Open it and set phar.readonly to Off.

; http://php.net/phar.readonly
phar.readonly = Off

if everything runs smoothly, dependencies are downloaded in to the vendor folder and .phar file is created in build folder.

Implementation

Now comes the fun part. In my case I have followed the example.md that is in example folder and I get error.

Error #1

Uncaught DI\Definition\Exception\DefinitionException: Entry "ICurler" cannot be resolved

which was cased by using builded .phar instead of source, or some kind of PHP black magic. And now — few hours later after resolving this obscure error, another sweet one:

Error #2

“error":"unauthorized_client","error_description":"The client id provided is not trusted"

Cool, at least connection to endpoint has been made. So I have looked into documentation to find this error code, but nothing about client_id. I have googled it and found nothing useful. So I have wrote to the support and get this answer:


… I’ve included my colleague Diego to the email chain, who takes care of API queries.

Diego has looked at your API key and made some amends and so your issue should be resolved now...


Nice, after 2 days I have made connection to the endpoint. What a beautiful, language, what a beautiful API. Here is my testing script:

References

Related Post

Convert HEIC to JPG on Right Click for Free Convert HEIC to JPG on Right-Click In iOS 11 Apple is replacing the JPEG image format with the new HEIC alternative. But what to do when device or p...
Right-Click to Translate (Look Up) with Google Tra... If you are not native english speaker, you may be frustrated with default "look up" options you get after selecting a text and right clicking. There a...
Free Better Battery Stats and Time Remaining for M... Better Battery Stats and Time Remaining for Mac OS TL;DR; Do you miss the time remaining indicator on your MacBook, MacBook Air, or MacBook Pro? He...
Right Click to Create New File on Mac OS X TL;DR; Windows has a lot of cons but it has also some pros. One of them is a smooth way to create empty file on right-click. Mac OS doesn't come with...
Convert HEIC to PNG on Right Click for Free Convert HEIC to PNG on Right-Click In iOS 11 Apple is replacing the PNG image format with the new HEIC alternative. But what to do when device or pr...
MacBook wifi issue – OS X keeps reconnecting Last few weeks I was facing annoying wifi problems. My mac was reconnecting every 5 minutes. On top of that BSSID was reseting so I saw BSSID changing...
Buy me a coffeeOut of coffee 😱, please help!