nfreear/cloudsight-http-client

HTTP client for CloudSight's image recognition API. (Not endorsed by CloudSight.)

1.0.0-alpha 2015-05-04 00:00 UTC

This package is not auto-updated.

Last update: 2024-04-13 15:11:58 UTC


README

Latest Stable Version MIT License Build status: Travis-CI

cloudsight-http-client

PHP HTTP client library for the CloudSight image recognition API, with mock API functionality.

Installation

Install using Composer, via Packagist. At the commandline / in a terminal, type:

composer require nfreear/cloudsight-http-client:dev-master

Usage

  1. Register with CloudSight to get an API key.

  2. At the commandline / in a terminal, type:

composer copy-env
  1. Edit the CS_API_KEY variable, in the example/.env configuration file, using your favourite text editor:
atom example/.env
  1. Try the command line example:
composer example
  1. And, a web server based example:
composer web

Note: you'll want to set the CS_MOCK variable to false, to run live demos!

Legacy

<?php
use Nfreear\Cloudsight\Cloudsight_Http_Client;

$client = new CloudSight_Http_Client($api_key);

$request = $client->postImageRequests($image_url);

while (1) {

    sleep(1);

    $result = $client->getImageResponses($request->token);

    // Check if analysis is complete.
    if ($client->isComplete()) {
        break;
    }
}

echo "Complete. ALT text: " . $result->name;
?>

NOTE: this library is NOT endorsed by CloudSight.

© 2016 Nick Freear. License: MIT.

author: @nfreear on Twitter