我正在尝试使用Microsoft Emotion API。
我可以使用图像版本而没有任何问题但是当我尝试使用视频版本时,我得到一个空的回复。
似乎我可以成功连接API,因为当我给它一个错误的文件类型时,它会返回正确的错误代码。
这是我的代码。非常感谢任何帮助!
<script type="text/javascript">
//apiKey: Replace this with your own Project Oxford Emotion API key, please do not use my key. I inlcude it here so you can get up and running quickly but you can get your own key for free at https://www.projectoxford.ai/emotion
var apiKey = "mykey";
//apiUrl: The base URL for the API. Find out what this is for other APIs via the API documentation
var apiUrl = "https://api.projectoxford.ai/emotion/v1.0/recognizeinvideo";
$('#btn').click(function () {
CallAPI("https://media.kairos.com/emodemo/videos/demo1.mp4", apiUrl, apiKey);
});
function CallAPI(fileUrl, apiUrl, apiKey)
{
$.ajax({
url: apiUrl,
beforeSend: function (xhrObj) {
xhrObj.setRequestHeader("Content-Type", "application/json");
xhrObj.setRequestHeader("Ocp-Apim-Subscription-Key", apiKey);
},
type: "POST",
data: '{"url": "' +fileUrl +'"}'
})
.done(function (response) {
console.log(response);
//ProcessResult(response);
})
.fail(function (error) {
$("#response").text(error.getAllResponseHeaders());
});
}
function ProcessResult(response)
{
var data = JSON.stringify(response);
$("#response").text(data);
}
</script>