调用Originality.ai AI检测API返回invalid api call错误的问题排查求助
各位大佬好,我最近在尝试调用Originality.ai的AI检测API,但是一直收到"invalid api call"的错误提示,实在找不到问题出在哪,想请大家帮忙排查下。
下面是我写的PHP代码:
function originlaity_ai() { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'https://api.originality.ai/api/v1//scan/ai'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, '{\"content\": \"A delicious cup of tea is a simple and timeless pleasure, and for many people its even more than that...\"}'); $headers = array(); $headers[] = 'Content-Type: application/json'; $headers[] = 'X-OAI-API-KEY: XXXXXXXXXXX'; curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); $result = curl_exec($ch); if (curl_errno($ch)) { echo 'Error:' . curl_error($ch); } var_dump($result); curl_close($ch); } originlaity_ai();
我对照了官方文档的要求,文档内容如下:
Making Requests
In order to use our API you'll need to create an API key on the "My Keys" table on the left or click this button:
To start making requests: Create a header key named X-OAI-API-KEY and use your api key as the value in your application of choiceMain Endpoint:
https://api.originality.ai/api/v1All Request responses are returned in JSON
AI Detection
[POST]
/scan/aiRun an AI Detection scan for a full piece of content
Request Example:
{
"content": "A delicious cup of tea is a simple and timeless pleasure, and for many people it's even more than that..."
}
我已经确认API密钥是正确的,也按照要求设置了Content-Type为application/json,但还是报错。有没有朋友能帮我看看代码里哪里有问题?比如URL的格式、POST数据的转义之类的?
备注:内容来源于stack exchange,提问作者Steve

