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
-
Register with CloudSight to get an API key.
-
At the commandline / in a terminal, type:
composer copy-env
- Edit the
CS_API_KEY
variable, in theexample/.env
configuration file, using your favourite text editor:
atom example/.env
- Try the command line example:
composer example
- 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.