Example of GettyImages API using Composer

With Using Composer, API works are much easier. It’s my best friend for implementing APIs.

  1. Register on GettyImages for Developers. You will get Email with API Keys
    Register on Gettyimages APIgettyimages developers Get API keys
  2. I need to get GettyImages API PHP from GitHub.
    composer.json file is already configured, so you don’t need to worry about anything.

    $ git clone https://github.com/gettyimages/gettyimages-api_php.git

     

  3. Install Composer.
    $ curl -sS https://getcomposer.org/installer | php
    $ php composer.phar install
    
  4. Create example  file like below.
    <?php
    require 'vendor/autoload.php';
    use GettyImages\Api\GettyImages_Client;
    
    $apiKey = "Your API KEY";
    $apiSecret = "Your Secret KEY";
    
    $client = new GettyImages_Client($apiKey,$apiSecret);
    
    $response = $client->Search()->Images()->withPhrase("dog")->execute();
    
    var_dump($response);

     

  5. Here we go! Json format is returned.
    GettyImages API php example

Thanks bud, Composer!

Composer PHP development

Simple way for uploading file to Amazon S3

I have one project for uploading video file to Amazon S3 server on PHP environment.

To get started with sample, download sample project.

git clone https://github.com/awslabs/aws-php-sample.git

Go to aws-php-sample folder and run. This will install composer.

curl -sS https://getcomposer.org/installer | php
php composer.phar install

 

Create testing php script.

<?php
require 'vendor/autoload.php';

use Aws\Exception\AwsException;
use Aws\S3\Exception\S3Exception;

$s3 = new Aws\S3\S3Client([
'version' => 'latest',
'region' => 'us-east-1',
'credentials' => [
'key' => 'AKXXXXXXXXXXXXXXXXXXQ',
'secret' => 'twHHXXXXXXXXX/XXXXXXXXXXXXXXXXXXXXXh'
],
'debug' => false
]);

$bucket = 'test-bucket';
$key = 'test.mp4';
$result = $s3->putObject([
'Bucket' => $bucket,
'Key' => $key,
'SourceFile' => '/home/titus/test/aws-php-sample/test.mp4',
]);

screen-shot-2016-11-10-at-10-34-39-am

Run sample from the url or command:

php test.php

If it is not working, change debug value as true. Then you can see what the problem is.

Simple is beautiful as always.