我的node.js web应用程序使用微软的ocr计算机视觉api
https://www.microsoft.com/cognitive-services/en-us/computer-vision-api当我传递一个静态链接到api,它工作
:
身体:"{"url":"LINK_TO_IMAGE"}",
是请求回调的一部分。
我想要的是动态传递链接。
调用回调函数变量link
我试过使用这个:
身体:{"url":链接},
但这不起作用,没有响应。
我还需要遵循其他格式吗?
看文档,这里https://dev.projectoxford.ai/docs/services/54ef139a49c3f70a50e79b7d/operations/5527970549c3f723cc5363e4
<!DOCTYPE html>
<html>
<head>
<title>JSSample</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
</head>
<body>
<script type="text/javascript">
$(function() {
var params = {
// Request parameters
"language": "unk",
"detectOrientation ": "true",
};
$.ajax({
url: "https://api.projectoxford.ai/vision/v1/ocr?" + $.param(params),
beforeSend: function(xhrObj){
// Request headers
xhrObj.setRequestHeader("Content-Type","application/json");
xhrObj.setRequestHeader("Ocp-Apim-Subscription-Key","{subscription key}");
},
type: "POST",
// Request body
data: "{body}",
})
.done(function(data) {
alert("success");
})
.fail(function() {
alert("error");
});
});
</script>
</body>
</html>