Skip to content

分配线路

当前伙伴的线路分配给终端账号

接口信息

  • 接口: /agent-api/new/user/{user_id}/line/{line_id}
  • 请求方式: POST
  • 需要鉴权: 是

路由参数

参数类型示例解释必填
user_idstring4d99d91c-f5d9-49da-88da-758977cc58a9主账户 id
line_idstring29c39ec4-b292-4af9-a88b-922d61866aag线路 id

请求参数

参数类型必填描述
line_concurrencyint分配并发
deadline_atstring截至时间
pricedouble价格

请求示例

cURL
curl -X POST "https://ai.api.longlonglong.cn/agent-api/new/user/4d99d91c-f5d9-49da-88da-758977cc58a9/line/29c39ec4-b292-4af9-a88b-922d61866aag" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{
    "line_concurrency": 1,
    "deadline_at": "2025-11-28 00:00:00",
    "price": 0
  }'
Go
package main

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

func main() {
    jsonData := []byte(`{
        "line_concurrency": 1,
        "deadline_at": "2025-11-28 00:00:00",
        "price": 0
    }`)

    client := &http.Client{}
    req, err := http.NewRequest("POST", "https://ai.api.longlonglong.cn/agent-api/new/user/4d99d91c-f5d9-49da-88da-758977cc58a9/line/29c39ec4-b292-4af9-a88b-922d61866aag", bytes.NewBuffer(jsonData))
    if err != nil {
        panic(err)
    }
    req.Header.Add("Content-Type", "application/json")
    req.Header.Add("Authorization", "Bearer YOUR_TOKEN")

    resp, err := client.Do(req)
    if err != nil {
        panic(err)
    }
    defer resp.Body.Close()

    body, _ := io.ReadAll(resp.Body)
    fmt.Println(string(body))
}
JavaScript
const axios = require('axios');

axios.post('https://ai.api.longlonglong.cn/agent-api/new/user/4d99d91c-f5d9-49da-88da-758977cc58a9/line/29c39ec4-b292-4af9-a88b-922d61866aag', {
    line_concurrency: 1,
    deadline_at: '2025-11-28 00:00:00',
    price: 0
}, {
    headers: {
        'Content-Type': 'application/json',
        'Authorization': 'Bearer YOUR_TOKEN'
    }
})
.then(response => {
    console.log(response.data);
})
.catch(error => {
    console.error(error);
});
Java
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

public class Main {
    public static void main(String[] args) throws Exception {
        HttpClient client = HttpClient.newHttpClient();
        String json = "{\"line_concurrency\": 1, \"deadline_at\": \"2025-11-28 00:00:00\", \"price\": 0}";
        HttpRequest request = HttpRequest.newBuilder()
            .uri(URI.create("https://ai.api.longlonglong.cn/agent-api/new/user/4d99d91c-f5d9-49da-88da-758977cc58a9/line/29c39ec4-b292-4af9-a88b-922d61866aag"))
            .header("Content-Type", "application/json")
            .header("Authorization", "Bearer YOUR_TOKEN")
            .POST(HttpRequest.BodyPublishers.ofString(json))
            .build();

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

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://ai.api.longlonglong.cn/agent-api/new/user/4d99d91c-f5d9-49da-88da-758977cc58a9/line/29c39ec4-b292-4af9-a88b-922d61866aag');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([
    'line_concurrency' => 1,
    'deadline_at' => '2025-11-28 00:00:00',
    'price' => 0
]));
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/new/user/4d99d91c-f5d9-49da-88da-758977cc58a9/line/29c39ec4-b292-4af9-a88b-922d61866aag'
headers = {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer YOUR_TOKEN'
}
data = {
    'line_concurrency': 1,
    'deadline_at': '2025-11-28 00:00:00',
    'price': 0
}

response = requests.post(url, json=data, 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) {
        curl_easy_setopt(curl, CURLOPT_URL, "https://ai.api.longlonglong.cn/agent-api/new/user/4d99d91c-f5d9-49da-88da-758977cc58a9/line/29c39ec4-b292-4af9-a88b-922d61866aag");
        std::string json_data = "{\"line_concurrency\": 1, \"deadline_at\": \"2025-11-28 00:00:00\", \"price\": 0}";
        curl_easy_setopt(curl, CURLOPT_POSTFIELDS, json_data.c_str());
        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_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;
}

成功响应

状态码: 200 OK

响应示例

json
{
    "code": 200,
    "status": "success",
    "message": "分配线路成功",
    "data": {
        "user_id": "310edbc9-ae93-4570-85ea-4734936dac1d",
        "line_id": "29c39ec4-b292-4af9-a88b-922d61866aag",
        "belong_user": "b6d94bef-5ac2-4c6e-ba13-d2f8f124862b",
        "remark": "yw代理-测试主账户1",
        "line_concurrency": 1,
        "deadline_at": "2025-11-28 00:00:00",
        "available_time": 31017600,
        "begin_at": "2024-12-04 14:31:00",
        "price": 0,
        "agent_cost": 0.13,
        "root_cost": 0,
        "updated_at": "2024-12-04 14:31:00",
        "created_at": "2024-12-04 14:31:00",
        "id": 13
    }
}

特殊情况响应

注意:一条线路,有且仅有分配一条线,给与一个用户,不可重复分配给同一个用户

json
{
    "code": 422,
    "status": "error",
    "message": "线路已绑定用户",
    "data": []
}

基于 MIT 许可发布