Appearance
设置用户过期时间
接口信息
- 接口:
/agent-api/user/{user_id}/expire_time - 请求方式:
PUT
路由参数
| 参数 | 类型 | 示例 | 解释 | 必填 |
|---|---|---|---|---|
| user_id | string | 5832d184-dd53-42a0-8ace-0bf8d660f4cc | 用户 id | 是 |
请求参数
| 参数 | 类型 | 示例 | 解释 | 必填 |
|---|---|---|---|---|
| expire_time | string | 2024/8/17 | 过期时间 | 是 |
请求示例
cURL
curl -X PUT "https://ai.api.longlonglong.cn/agent-api/user/5832d184-dd53-42a0-8ace-0bf8d660f4cc/expire_time" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_TOKEN" \
-d '{
"expire_time": "2024-08-17"
}'Go
package main
import (
"bytes"
"encoding/json"
"fmt"
"io"
"net/http"
)
func main() {
url := "https://ai.api.longlonglong.cn/agent-api/user/5832d184-dd53-42a0-8ace-0bf8d660f4cc/expire_time"
data := map[string]string{
"expire_time": "2024-08-17",
}
jsonData, _ := json.Marshal(data)
req, _ := http.NewRequest("PUT", 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 = "5832d184-dd53-42a0-8ace-0bf8d660f4cc";
const url = `https://ai.api.longlonglong.cn/agent-api/user/${userId}/expire_time`;
const data = {
expire_time: "2024-08-17"
};
fetch(url, {
method: "PUT",
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 = "{\"expire_time\":\"2024-08-17\"}";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://ai.api.longlonglong.cn/agent-api/user/5832d184-dd53-42a0-8ace-0bf8d660f4cc/expire_time"))
.header("Content-Type", "application/json")
.header("Authorization", "Bearer YOUR_TOKEN")
.PUT(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 = [
"expire_time" => "2024-08-17"
];
curl_setopt_array($curl, [
CURLOPT_URL => "https://ai.api.longlonglong.cn/agent-api/user/5832d184-dd53-42a0-8ace-0bf8d660f4cc/expire_time",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => "PUT",
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 = "5832d184-dd53-42a0-8ace-0bf8d660f4cc"
url = f"https://ai.api.longlonglong.cn/agent-api/user/{user_id}/expire_time"
data = {
"expire_time": "2024-08-17"
}
headers = {
"Content-Type": "application/json",
"Authorization": "Bearer YOUR_TOKEN"
}
response = requests.put(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 = "{\"expire_time\":\"2024-08-17\"}";
curl_easy_setopt(curl, CURLOPT_URL, "https://ai.api.longlonglong.cn/agent-api/user/5832d184-dd53-42a0-8ace-0bf8d660f4cc/expire_time");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data);
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "PUT");
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": []
}错误响应
条件: 过期时间设置为当天/未设置过期时间。
状态码: 200 OK
响应示例:
json
{
"code": 422,
"status": "error",
"message": "到期时间最少设置一天",
"data": []
}