0

I'm wondering how to use the emotion API from microsoft: https://dev.projectoxford.ai/docs/services/5639d931ca73072154c1ce89/operations/563b31ea778daf121cc3a5fa

I've installed the HTTP_Request2 package with pear on my Ubuntu 14.04.3 server

When I use this code, I get a blank page.

<?php
// This sample uses the Apache HTTP client from HTTP Components (http://hc.apache.org/httpcomponents-client-ga/)
require_once 'HTTP/Request2.php';

$request = new Http_Request2('https://api.projectoxford.ai/emotion/v1.0/recognize');

$url = $request->getUrl();

$headers = array(
  // Request headers
  'Content-Type' => 'application/json',
  'Ocp-Apim-Subscription-Key' => 'XXXXX'
);

$request->setHeader($headers);


$parameters = array(
// Request parameters
);

$url->setQueryVariables($parameters);

$request->setMethod(HTTP_Request2::METHOD_POST);

// Request body
$request->setBody('{"url": "http://images.wisegeek.com/triangular-face.jpg"}');

try
{
  $response = $request->send();
  echo $response->getBody();    
}
catch (HttpException $ex)
{
echo $ex;

}

?>

I've looked through the error logs and found this error:

[Fri Jun 10 11:57:47.419702 2016] [:error] [pid 6851] [client 145.76.251.26:55354] PHP Fatal error: Uncaught \n HTTP_Request2_ConnectionException: Unable to connect to ssl://api.projectoxford.ai:443. Error: stream_socket_client(): unable to connect to ssl://api.projectoxford.ai:443 (Unknown error)\nstream_socket_client(): Failed to enable crypto\nstream_socket_client(): SSL operation failed with code 1. OpenSSL Error messages:\nerror:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed in /usr/share/php/HTTP/Request2/Adapter/Socket.php on line 325\nException trace\n#FunctionLocation\n0

Steven
  • 21
  • 7

0 Answers0