Appearance
子账户注册
接口信息
- 接口:
/agent-api/user/{user_id}/subset_users - 请求方式:
POST
路由参数
| 参数 | 类型 | 示例 | 解释 | 必填 |
|---|---|---|---|---|
| user_id | string | 5433b412-07d5-44e6-9fa4-deb65e43bc93 | 用户 id | 是 |
请求参数
| 参数 | 类型 | 示例 | 解释 | 必填 |
|---|---|---|---|---|
| name | String | 子账户 1 | 账户名 | 是 |
| String | 12345678@qq.com | 邮箱 | 是 | |
| phone | int | 12345678 | 手机号码 | 是 |
| password | String | 123456 | 密码 | 是 |
| password_confirmation | String | 123456 | 重复密码 | 是 |
| subset_data | object | - | 其他信息 | 否 |
| alias | String | 账号 1 | 别名 | 否 |
| birthday | date | 2022/7/13 | 生日 | 否 |
| duty | String | 员工 | 职位 | 否 |
| String | wx123456 | 微信 | 否 | |
| String | 123456 | 否 | ||
| landline_phone | String | 010-123132 | 座机 | 否 |
| sex | String | 0 | 性别 0:未知 1:男 2:女 | 否 |
请求示例
cURL
curl -X POST "https://ai.api.longlonglong.cn/agent-api/user/5433b412-07d5-44e6-9fa4-deb65e43bc93/subset_users" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_TOKEN" \
-d '{
"name": "子账户1",
"email": "12345678@qq.com",
"phone": "12345678",
"password": "123456",
"password_confirmation": "123456",
"subset_data": {
"alias": "账号1",
"birthday": "2022-07-13",
"duty": "员工",
"wechat": "wx123456",
"qq": "123456",
"landline_phone": "010-123132",
"sex": 0
}
}'Go
package main
import (
"bytes"
"encoding/json"
"fmt"
"io"
"net/http"
)
func main() {
url := "https://ai.api.longlonglong.cn/agent-api/user/5433b412-07d5-44e6-9fa4-deb65e43bc93/subset_users"
data := map[string]interface{}{
"name": "子账户1",
"email": "12345678@qq.com",
"phone": "12345678",
"password": "123456",
"password_confirmation": "123456",
"subset_data": map[string]interface{}{
"alias": "账号1",
"birthday": "2022-07-13",
"duty": "员工",
"wechat": "wx123456",
"qq": "123456",
"landline_phone": "010-123132",
"sex": 0,
},
}
jsonData, _ := json.Marshal(data)
req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
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 userId = "5433b412-07d5-44e6-9fa4-deb65e43bc93";
const url = `https://ai.api.longlonglong.cn/agent-api/user/${userId}/subset_users`;
const data = {
name: "子账户1",
email: "12345678@qq.com",
phone: "12345678",
password: "123456",
password_confirmation: "123456",
subset_data: {
alias: "账号1",
birthday: "2022-07-13",
duty: "员工",
wechat: "wx123456",
qq: "123456",
landline_phone: "010-123132",
sex: 0
}
};
fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": "Bearer YOUR_TOKEN"
},
body: JSON.stringify(data)
})
.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();
String body = "{\"name\":\"子账户1\",\"email\":\"12345678@qq.com\",\"phone\":\"12345678\",\"password\":\"123456\",\"password_confirmation\":\"123456\",\"subset_data\":{\"alias\":\"账号1\",\"birthday\":\"2022-07-13\",\"duty\":\"员工\",\"wechat\":\"wx123456\",\"qq\":\"123456\",\"landline_phone\":\"010-123132\",\"sex\":0}}";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://ai.api.longlonglong.cn/agent-api/user/5433b412-07d5-44e6-9fa4-deb65e43bc93/subset_users"))
.header("Content-Type", "application/json")
.header("Authorization", "Bearer YOUR_TOKEN")
.POST(HttpRequest.BodyPublishers.ofString(body))
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}PHP
<?php
$curl = curl_init();
$data = [
"name" => "子账户1",
"email" => "12345678@qq.com",
"phone" => "12345678",
"password" => "123456",
"password_confirmation" => "123456",
"subset_data" => [
"alias" => "账号1",
"birthday" => "2022-07-13",
"duty" => "员工",
"wechat" => "wx123456",
"qq" => "123456",
"landline_phone" => "010-123132",
"sex" => 0
]
];
curl_setopt_array($curl, [
CURLOPT_URL => "https://ai.api.longlonglong.cn/agent-api/user/5433b412-07d5-44e6-9fa4-deb65e43bc93/subset_users",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => json_encode($data),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"Authorization: Bearer YOUR_TOKEN"
],
]);
$response = curl_exec($curl);
curl_close($curl);
echo $response;Python
import requests
import json
user_id = "5433b412-07d5-44e6-9fa4-deb65e43bc93"
url = f"https://ai.api.longlonglong.cn/agent-api/user/{user_id}/subset_users"
data = {
"name": "子账户1",
"email": "12345678@qq.com",
"phone": "12345678",
"password": "123456",
"password_confirmation": "123456",
"subset_data": {
"alias": "账号1",
"birthday": "2022-07-13",
"duty": "员工",
"wechat": "wx123456",
"qq": "123456",
"landline_phone": "010-123132",
"sex": 0
}
}
headers = {
"Content-Type": "application/json",
"Authorization": "Bearer YOUR_TOKEN"
}
response = requests.post(url, data=json.dumps(data), headers=headers)
print(response.json())C++
#include <iostream>
#include <curl/curl.h>
#include <string>
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");
const char* data = "{\"name\":\"子账户1\",\"email\":\"12345678@qq.com\",\"phone\":\"12345678\",\"password\":\"123456\",\"password_confirmation\":\"123456\",\"subset_data\":{\"alias\":\"账号1\",\"birthday\":\"2022-07-13\",\"duty\":\"员工\",\"wechat\":\"wx123456\",\"qq\":\"123456\",\"landline_phone\":\"010-123132\",\"sex\":0}}";
curl_easy_setopt(curl, CURLOPT_URL, "https://ai.api.longlonglong.cn/agent-api/user/5433b412-07d5-44e6-9fa4-deb65e43bc93/subset_users");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data);
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;
}返回示例
json
{
"code": 200,
"status": "success",
"message": "添加子账户成功",
"data": {
"id": "01c80030-28ef-4d0b-a2ef-2475a0504e32",
"name": "子账户1",
"email": "12345678@qq.com",
"phone": "12345678"
}
}