Skip to content

公海自定义组件初始化

接口信息

  • 接口: /agent-api/user/{user_id}/customer/create
  • 请求方式: GET

路由参数

参数类型示例解释必填
user_idstring5832d184-dd53-42a0-8ace-0bf8d660f4cc用户 id(主账号)

请求示例

cURL
curl -X GET "https://ai.api.longlonglong.cn/agent-api/user/5832d184-dd53-42a0-8ace-0bf8d660f4cc/customer/create" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN"
Go
package main

import (
    "fmt"
    "io"
    "net/http"
)

func main() {
    client := &http.Client{}
    req, _ := http.NewRequest("GET", "https://ai.api.longlonglong.cn/agent-api/user/5832d184-dd53-42a0-8ace-0bf8d660f4cc/customer/create", nil)
    req.Header.Add("Content-Type", "application/json")
    req.Header.Add("Authorization", "Bearer YOUR_TOKEN")
    resp, _ := client.Do(req)
    defer resp.Body.Close()
    body, _ := io.ReadAll(resp.Body)
    fmt.Println(string(body))
}
JavaScript
const response = await fetch("https://ai.api.longlonglong.cn/agent-api/user/5832d184-dd53-42a0-8ace-0bf8d660f4cc/customer/create", {
    method: "GET",
    headers: {
        "Content-Type": "application/json",
        "Authorization": "Bearer YOUR_TOKEN"
    }
});
const data = await response.json();
console.log(data);
Java
import java.net.HttpURLConnection;
import java.net.URL;
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws Exception {
        URL url = new URL("https://ai.api.longlonglong.cn/agent-api/user/5832d184-dd53-42a0-8ace-0bf8d660f4cc/customer/create");
        HttpURLConnection conn = (HttpURLConnection) url.openConnection();
        conn.setRequestMethod("GET");
        conn.setRequestProperty("Content-Type", "application/json");
        conn.setRequestProperty("Authorization", "Bearer YOUR_TOKEN");
        BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream()));
        String line;
        StringBuilder response = new StringBuilder();
        while ((line = br.readLine()) != null) {
            response.append(line);
        }
        br.close();
        System.out.println(response.toString());
    }
}
PHP
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://ai.api.longlonglong.cn/agent-api/user/5832d184-dd53-42a0-8ace-0bf8d660f4cc/customer/create");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    "Content-Type: application/json",
    "Authorization: Bearer YOUR_TOKEN"
]);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
?>
Python
import requests

url = "https://ai.api.longlonglong.cn/agent-api/user/5832d184-dd53-42a0-8ace-0bf8d660f4cc/customer/create"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN"
}
response = requests.get(url, headers=headers)
print(response.json())
C++
#include <iostream>
#include <curl/curl.h>

int main() {
    CURL* curl = curl_easy_init();
    if (curl) {
        struct curl_slist* headers = NULL;
        headers = curl_slist_append(headers, "Content-Type: application/json");
        headers = curl_slist_append(headers, "Authorization: Bearer YOUR_TOKEN");
        curl_easy_setopt(curl, CURLOPT_URL, "https://ai.api.longlonglong.cn/agent-api/user/5832d184-dd53-42a0-8ace-0bf8d660f4cc/customer/create");
        curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
        CURLcode res = curl_easy_perform(curl);
        curl_easy_cleanup(curl);
    }
    return 0;
}

返回结果

json
{
    "code": 200,
    "status": "success",
    "message": "查看公海创建模板成功",
    "data": [
        {
            "id": "91a4ff5d-3d14-4b85-a062-a3468e48f4be",
            "name": "姓名",
            "type": "text",
            "sort": 0,
            "validate": [
                "required"
            ]
        },
        {
            "id": "c87d8629-7cfd-4980-bb3a-7827bff4b72c",
            "name": "数字",
            "type": "number",
            "sort": 1,
            "validate": [
                "integer"
            ]
        }
    ]
}

字段说明

字段说明
id公海组件ID
name公海组件名称
type公海组件类型
sort公海组件排序
validate公海组件验证规则,required必填,sometimes存在时则验证

基于 MIT 许可发布