juicekit / watson
A PHP implementation of IBM's Watson REST API
dev-master
2016-09-30 03:41 UTC
Requires
- guzzlehttp/guzzle: ~6.0
Requires (Dev)
- codacy/coverage: dev-master
- phpunit/phpunit: 5.5.*
This package is not auto-updated.
Last update: 2024-11-09 20:17:45 UTC
README
JuiceKit Watson is a PHP implementation of IBM's Watson REST API.
Note: Currently, only the VisualRecognition API is supported, other APIs will be supported in the future. For more information on available Watson APIs visit http://www.ibm.com/watson/developercloud/
Installation
composer require juicekit/watson
Example Usage
Classify an image from a url or file
<?php
require_once '../vendor/autoload.php';
use JuiceKit\Watson as Watson;
$visualRecognition = new Watson\VisualRecognition\v3\VisualRecognition('YOUR_API_KEY', 'YOUR_VERSION');
/**
* $responseWithImageUrl = [
* 'custom_classes'=> 0,
* 'images'=> [
* [
* 'classifiers'=> [
* 'classes'=> [
* [
* 'class'=> 'person',
* 'score'=> '0.999999',
* 'type_hierarchy'=> '/people'
* ]
* ],
* 'classifier_id'=> 'default',
* 'name'=> 'default'
* ]
* ]
* ],
* 'images_processed'=> 1
* ]
*/
$responseWithImageUrl = $visualRecognition->classify('http://your-image-resource.com/image.jpg');
$imageResource = fopen('your-image.jpg', 'r');
/**
* $responseWithImageFile = [
* 'custom_classes'=> 0,
* 'images'=> [
* [
* 'classifiers'=> [
* 'classes'=> [
* [
* 'class'=> 'person',
* 'score'=> '0.999999',
* 'type_hierarchy'=> '/people'
* ]
* ],
* 'classifier_id'=> 'default',
* 'name'=> 'default'
* ]
* ]
* ],
* 'images_processed'=> 1
* ]
*/
$responseWithImageFile = $visualRecognition->classify($imageResource);