我想知道如何使用microsoft的情感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():无法启用crypto \ nstream_socket_client():SSL操作失败,代码为1. OpenSSL错误消息: \ nerror:14090086:SSL例程:SSL3_GET_SERVER_CERTIFICATE: /usr/share/php/HTTP/Request2/Adapter/Socket.php 中的证书验证失败 325 \ n异常跟踪\ n#FunctionLocation \ N0