0

我想知道如何使用来自微软的情感 API:https ://dev.projectoxford.ai/docs/services/5639d931ca73072154c1ce89/operations/563b31ea778daf121cc3a5fa

我已经在我的 Ubuntu 14.04.3 服务器上安装了带有 pear 的 HTTP_Request2 包

当我使用此代码时,我得到一个空白页。

<?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;

}

?>

我查看了错误日志,发现了这个错误:

[Fri Jun 10 11:57:47.419702 2016] [:error] [pid 6851] [client 145.76.251.26:55354] PHP 致命错误:未捕获 \n HTTP_Request2_ConnectionException:无法连接到 ssl://api.projectoxford.ai: 443. 错误:stream_socket_client():无法连接到 ssl://api.projectoxford.ai:443(未知错误)\nstream_socket_client():无法启用加密\nstream_socket_client():SSL 操作失败,代码为 1。OpenSSL 错误消息: \n错误:14090086:SSL 例程:SSL3_GET_SERVER_CERTIFICATE:证书验证在/usr/share/php/HTTP/Request2/Adapter/Socket.php第325行失败 \n异常跟踪\n#FunctionLocation\n0

4

0 回答 0