如何解决更新 watsonplatform.net 端点以进行情感分析,得到 404
我按照 IBM 的电子邮件说明(服务凭证 URL 和 api)更新了 Watson 端点,当我执行调用时,我收到“404 Not Found”。
网址是
https://api.eu-gb.natural-language-understanding.watson.cloud.ibm.com/instances/2xxxxx43-52ac-4xx5-922d-cxxxxx5ea52b
编辑: 这是我正在做的测试(和我用于在实时环境中分析文本的代码相同):
function Analyse($text)
{
$body = '{
"text": "' . addslashes($text) . '","features": {
"sentiment": {}
}
}';
$url = "https://api.eu-gb.natural-language-understanding.watson.cloud.ibm.com/instances/2xxxxx43-52ac-4xx5-922d-cxxxxx5ea52b";
$key = "ukLuEL.........qinV";
$response = Request::post($url)
->authenticateWith('apikey',$key)// authenticate with basic auth...
->body($body)
->sendsJson()
->send();
$body = $response->body; // <<<<< THIS MESSAGE STATES "NOT FOUND 404"
$sentiment = $body->sentiment->document;
return [
"label" => $sentiment->label,"score" => $sentiment->score
];
}
如果我将旧凭据替换回来,它会起作用并返回情绪。旧网址是:
https://gateway-lon.watsonplatform.net/natural-language-understanding/api/v1/analyze?version=2018-03-19
解决方法
确保不要仅用基本 URI 替换旧的完整路径。请参阅 API docs for IBM Watson Natural Language Understanding 以了解基本 URI 和各个 API 函数的路径。
因此,这个 URI:
https://gateway-lon.watsonplatform.net/natural-language-understanding/api/v1/analyze?version=2018-03-19
应该变成
https://api.eu-gb.natural-language-understanding.watson.cloud.ibm.com/instances/2xxxxx43-52ac-4xx5-922d-cxxxxx5ea52b//v1/analyze?version=2021-03-25
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。