Skip to content

用户列表

接口信息

  • 接口: /users?tenant_id={tenant_id}
  • 请求方式: GET
  • 需要鉴权: 是

注意事项

原接口GET /users 新增参数tenant_id,可筛选不同云节点上的用户

请求参数

参数类型必填描述
tenant_idstring租户id

请求示例

cURL
curl -X GET "https://ai.api.longlonglong.cn/users?tenant_id=f2d216a3-9ea5-4f1d-a170-ce9ebed41eaf" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN"
Go
package main

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

func main() {
    url := "https://ai.api.longlonglong.cn/users?tenant_id=f2d216a3-9ea5-4f1d-a170-ce9ebed41eaf"

    req, _ := http.NewRequest("GET", url, nil)
    req.Header.Set("Content-Type", "application/json")
    req.Header.Set("Authorization", "Bearer YOUR_TOKEN")

    client := &http.Client{}
    resp, _ := client.Do(req)
    defer resp.Body.Close()

    body, _ := io.ReadAll(resp.Body)
    fmt.Println(string(body))
}
JavaScript
const url = "https://ai.api.longlonglong.cn/users?tenant_id=f2d216a3-9ea5-4f1d-a170-ce9ebed41eaf";

fetch(url, {
  method: "GET",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN"
  }
})
  .then(response => response.json())
  .then(data => console.log(data))
  .catch(error => console.error("Error:", error));
Java
import java.net.URI;
import java.net.http.*;
import java.io.IOException;

public class Main {
    public static void main(String[] args) throws IOException, InterruptedException {
        HttpClient client = HttpClient.newHttpClient();
        HttpRequest request = HttpRequest.newBuilder()
            .uri(URI.create("https://ai.api.longlonglong.cn/users?tenant_id=f2d216a3-9ea5-4f1d-a170-ce9ebed41eaf"))
            .header("Content-Type", "application/json")
            .header("Authorization", "Bearer YOUR_TOKEN")
            .GET()
            .build();

        HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
        System.out.println(response.body());
    }
}
PHP
<?php

$curl = curl_init();

curl_setopt_array($curl, [
    CURLOPT_URL => "https://ai.api.longlonglong.cn/users?tenant_id=f2d216a3-9ea5-4f1d-a170-ce9ebed41eaf",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        "Content-Type: application/json",
        "Authorization: Bearer YOUR_TOKEN"
    ],
]);

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

echo $response;
Python
import requests

url = "https://ai.api.longlonglong.cn/users"
params = {"tenant_id": "f2d216a3-9ea5-4f1d-a170-ce9ebed41eaf"}
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN"
}

response = requests.get(url, params=params, headers=headers)

print(response.json())
C++
#include <iostream>
#include <curl/curl.h>

size_t WriteCallback(void* contents, size_t size, size_t nmemb, void* userp) {
    ((std::string*)userp)->append((char*)contents, size * nmemb);
    return size * nmemb;
}

int main() {
    CURL* curl;
    CURLcode res;
    std::string readBuffer;

    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/users?tenant_id=f2d216a3-9ea5-4f1d-a170-ce9ebed41eaf");
        curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
        curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback);
        curl_easy_setopt(curl, CURLOPT_WRITEDATA, &readBuffer);

        res = curl_easy_perform(curl);
        if(res != CURLE_OK)
            fprintf(stderr, "curl_easy_perform() failed: %s\n", curl_easy_strerror(res));
        else
            std::cout << readBuffer << std::endl;

        curl_easy_cleanup(curl);
    }
    return 0;
}

成功响应

条件: 鉴权校验通过,且云节点id存在。

状态码: 200 OK

响应示例*: 将返回该云节点下的用户列表:

json
{
    "code": 200,
    "status": "success",
    "message": "查看用户列表成功",
    "data": [
        {
            "id": "173d8501-b6a3-4869-a87e-71807bfd4fb8",
            "name": "测试 33",
            "phone": "12311111111",
            "email": "test33@aicall.net",
            "tenant_id": "f2d216a3-9ea5-4f1d-a170-ce9ebed41eaf",
            "created_at": "2022-06-09 13:44:54",
            "updated_at": "2022-06-09 13:44:54"
        }
    ]
}

返回参数说明

字段类型描述
idstring该用户的 id
namestring该用户的名称
phonestring该用户的手机号
emailstring该用户的邮箱
tenant_idstring云节点 id
created_atstring创建时间
updated_atstring更新时间

错误响应

条件: 请求的云节点id不存在。

状态码: 200

响应示例: 将不返回任何用户。

json
{
    "code": 200,
    "status": "success",
    "message": "查看用户列表成功",
    "data": []
}

注意事项

基于 MIT 许可发布