Git Product home page Git Product logo

gettyimages-api_php's Introduction

Getty Images API SDK - PHP

Build Status

Introduction

This SDK makes using the Getty Images API easy. It handles credential management, makes HTTP requests and is written with a fluent style in mind. For more info about the API, see the Documentation.

  • Search for images and videos from our extensive creative and editorial catalogs.
  • Get image and video metadata.
  • Download files using your Getty Images products (e.g., Editorial subscriptions, Easy Access, Thinkstock Subscriptions, and Image Packs).
  • Custom Request functionality that allows user to call any endpoint.

Help & Support

Getting started

Obtain an API Key

If you don't already have an API key, fill out and submit the contact form to be connected to our Sales team.

Installing the package

The SDK is available on Packagist.

Examples

See example.md for examples.

Building From Source Code

Source code is only needed if you would like to contribute to the project. Otherwise, use the package

Initial Setup

Assumptions

  • You have PHP >=7.2 setup

PHP.ini settings to build the code

[Phar]
; http://php.net/phar.readonly
phar.readonly = Off

//Extensions needed for Windows OSs
extension=php_curl.dll
extension=php_mbstring.dll
extension=php_exif.dll
extension=php_sockets.dll
extension=php_openssl.dll

Install via Composer

Please refer to README_ComposerInstall.md

Quick Build

If everything is setup on your machine where PHP will run, you can most likely run BuildSDK.bat or Build.sh to automatically build the phar. If something fails please read the error messages, PHP can have a finicky setup if you've never tried to use it to build a package before.

Windows

build.bat

Linux / OSX

Prerequisites

On Ubuntu, you may need to install a few additional packages

sudo apt update
sudo apt install php-xml php-mbstring

Building

./build.sh

This will put GettyImagesApi.phar in a build folder. Then you can use the package as you would any other phar.

The build does a few things for you automatically

  1. Determines if you have composer.phar and will retrieve it if you don't have it
  2. Runs composer install to get dependencies that are outlined in the composer.json file
  3. Then produces the phar file in ./build/GettyImagesApi.phar

Manually Installing PHP libraries

BuildSDK should get all the dependencies for you but if you want to do the update without a build From the root of the repository

php composer.phar install

If you want the test dependencies

php composer.phar install --require-dev

This command should install PHPUnit and any other php dependency libraries

Environment variables of interest

The sdk does support using a proxy directly as well as ignoring ssl validation errors. This can be configured through the existense environment variables

GettyImagesApi_IgnoreSSLValidation
GettyImagesApi_UseProxy

*nix Shell Example:

export GettyImagesApi_IgnoreSSLValidation=TRUE
export GettyImagesApi_UseProxy=127.0.0.0:8888

Windows CMD Example:

set GettyImagesApi_IgnoreSSLValidation=TRUE
set GettyImagesApi_UseProxy=127.0.0.0:8888

Powershell Example

$env:GettyImagesApi_IgnoreSSLValidation=TRUE
$env:GettyImagesApi_UseProxy="127.0.0.0:8888"

Tests

Running unit tests

The test project contains unit tests written using the PHPUnit Framwork.

Execute the unit tests

Assumptions

  • You have PHPUnit installed

To execute all of the unit tests: ./vendor/bin/phpunit --bootstrap vendor/autoload.php unitTests/.

To execute one test class: ./vendor/bin/phpunit --bootstrap vendor/autoload.php unitTests/EXAMPLETEST

Maintainers

To publish a new version to Packagist, create a new release with an updated tag. A webhook will notify Packagist to grab the latest version.

gettyimages-api_php's People

Contributors

caseymacpherson avatar chrissimmons avatar ionutcalara avatar jeffgoo avatar jphillips-gettyimages avatar mapitman avatar mtreuberg avatar paulkruggetty avatar sarukod avatar ssterli2 avatar sweetviper avatar technosailor avatar tuco86 avatar willjw avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gettyimages-api_php's Issues

PHP-DI 6.x causes bug due to removed function

PR #16 enabled usages of newer versions of PHP-DI, however it also introduced a bug due to the removal of the DI\object() function in PHP-DI 6.x:

[30-Sep-2021 14:10:29 UTC] PHP Fatal error:  Uncaught Error: Call to undefined function DI\Object() in /var/www/html/vendor/gettyimages/gettyimages-api/src/GettyImages_Client.php:102
Stack trace:
#0 /var/www/html/vendor/gettyimages/gettyimages-api/src/GettyImages_Client.php(121): GettyImages\Api\GettyImages_Client->__construct()
#1 /var/www/html/app/getty/container.php(41): 

(partial stack trace)

Note the removal in PHP-DI's upgrade guide: https://github.com/PHP-DI/PHP-DI/blob/master/doc/migration/6.0.md#diobject

Support access token

Hi there,

I found the OAuth refresh token scenario where I can authenticate with that, but I couldn't find any way to bypass that in case I stored the access token. Is this possible?

Deprecation warning: Optional parameter declared before required parameter in WebHelper

Using the library in Version "gettyimages/gettyimages-api": "^5.1" triggers deprecation warnings like this:

PHP Deprecated:  Optional parameter $options declared before required parameter $filepath is implicitly treated as a required parameter in /[...]/vendor/gettyimages/gettyimages-api/src/Request/WebHelper.php on line 104

I already opened a PR to fix it: #26

Fix build

The automated build is not running for pull requests and pushes to main. Looks like a simple fix in the build.yml file.

Setting "accept-language" header

Hey guys,

as far as I can see there is no other possibility to set the "accept-language" header other than by changing the source code of your php SDK. Or am I missing here something? It would be really handy if I could set additional curl options e. g. via a method in der FluentRequest class which will pass the options to the WebHelper object once it has been created. Is something like that planned in the near future or am I on my own on this?

Thanks,
Andreas

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.