originality.ai API 请求,{"error":"invalid api call"}",问题出在哪里?

问题描述 投票:0回答:1
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();

医生说 提出要求

  1. 为了使用我们的 API,您需要在左侧的“我的密钥”表中创建一个 API 密钥,或者单击此按钮:

  2. 要开始发出请求:创建一个名为 X-OAI-API-KEY 的标头密钥,并使用您的 api 密钥作为您选择的应用程序中的值

  3. 主要端点: https://api.originality.ai/api/v1

  4. 所有请求响应均以 JSON 格式返回

人工智能检测 [邮政] /扫描/ai

对整段内容运行人工智能检测扫描

请求示例:

{ "content": "一杯美味的茶是一种简单而永恒的乐趣,对许多人来说,它甚至不止于此......" }

php curl
1个回答
0
投票
$url = "https://api.originality.ai/api/v1/scan/ai";
$headerKey = "xxxx";
$data = array (
        "title" => "test title",
        "content" => "A delicious cup of tea is a simple and timeless pleasure, and for many people its even more than that"
);
$jsonData = json_encode ( $data );



$ch = curl_init ( $url );

curl_setopt ( $ch, CURLOPT_POST, 1 );
curl_setopt ( $ch, CURLOPT_POSTFIELDS, $jsonData );
curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, true );

curl_setopt ( $ch, CURLOPT_HTTPHEADER, array (
        'Content-Type: application/json',
        'X-OAI-API-KEY:' . $headerKey
) );

$response = curl_exec ( $ch );
curl_close ( $ch );

echo $response;
© www.soinside.com 2019 - 2024. All rights reserved.