IPRoyal Documentation
CN
CN
  • 概述
  • 代理
    • 皇家住宅代理
      • 仪表板
        • 统计数据
        • 配置
          • 自动充值
          • 代理访问
          • 白名单IP
          • 跳过IP
          • 权限管理
        • 订单
        • 子用户
      • 代理
        • 位置
        • 轮换类型
        • 高端池
        • 跳过静态ISP
        • IP白名单
        • 跳过IP
        • 权限管理
        • 协议
        • 提出请求
      • 子用户
      • API
        • 会话
        • 用户
        • 访问
        • 子用户
        • 白名单
        • 跳过IP
      • 域名访问条款
    • 静态住宅代理
      • 仪表板
        • 订单
        • 订单配置
        • 续期订单
      • 使用代理字符串
      • API
        • 用户
        • 产品
        • 订单
        • 代理
    • 数据中心代理
      • 仪表板
        • 订单
        • 订单配置
        • 续期订单
      • 使用代理字符串
      • API
        • 用户
        • 产品
        • 订单
        • 代理
    • 移动代理
      • 仪表板
        • 订单
        • 订单配置
        • 续期订单
      • 使用代理字符串
      • 故障排除
      • API
        • 用户
        • 代理
Powered by GitBook
On this page
  1. 代理
  2. 皇家住宅代理
  3. API

会话

删除会话

DELETE /sessions

正文参数

名称
类型
描述

residential_user_hashes

数组

用于重置会话的用户哈希数组

請求範例:

curl -X DELETE https://resi-api.iproyal.com/v1/sessions \
     -H "Authorization: Bearer <your_api_token>" \
     -H "Content-Type: application/json" \
     -d '{"residential_user_hashes":["hash1","hash2","hash3"]}'
<?php
$api_token = '<your_api_token>';
$url = 'https://resi-api.iproyal.com/v1/sessions';
$residential_user_hashes = ['hash1', 'hash2', 'hash3'];
$data = json_encode(['residential_user_hashes' => $residential_user_hashes]);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$headers = [
    "Authorization: Bearer $api_token",
    "Content-Type: application/json"
];
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);

if (curl_errno($ch)) {
    echo 'Error:' . curl_error($ch);
} else {
    echo $response;
}

curl_close($ch);
?>
import requests

api_token = '<your_api_token>'
url = 'https://resi-api.iproyal.com/v1/sessions'
residential_user_hashes = ['hash1', 'hash2', 'hash3']
data = {'residential_user_hashes': residential_user_hashes}

headers = {
    'Authorization': f'Bearer {api_token}',
    'Content-Type': 'application/json'
}

response = requests.delete(url, headers=headers, json=data)

print(response.text)
const https = require('https');

const apiToken = '<your_api_token>';
const url = 'https://resi-api.iproyal.com/v1/sessions';
const residentialUserHashes = ['hash1', 'hash2', 'hash3'];
const data = JSON.stringify({ residential_user_hashes: residentialUserHashes });

const options = {
  method: 'DELETE',
  headers: {
    'Authorization': `Bearer ${apiToken}`,
    'Content-Type': 'application/json',
    'Content-Length': data.length
  }
};

const req = https.request(url, options, (res) => {
  let responseData = '';

  res.on('data', (chunk) => {
    responseData += chunk;
  });

  res.on('end', () => {
    console.log(responseData);
  });
});

req.on('error', (error) => {
  console.error('Error:', error.message);
});

req.write(data);
req.end();
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 {
        String apiToken = "<your_api_token>";
        String url = "https://resi-api.iproyal.com/v1/sessions";

        String requestBody = "{\"residential_user_hashes\": [\"hash1\", \"hash2\", \"hash3\"]}";

        HttpClient client = HttpClient.newHttpClient();
        HttpRequest request = HttpRequest.newBuilder()
                .uri(URI.create(url))
                .header("Authorization", "Bearer " + apiToken)
                .header("Content-Type", "application/json")
                .header("X-HTTP-Method-Override", "DELETE")
                .POST(HttpRequest.BodyPublishers.ofString(requestBody))
                .build();

        HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());

        System.out.println(response);
}
package main

import (
	"bytes"
	"encoding/json"
	"fmt"
	"io"
	"log"
	"net/http"
)

const (
	apiToken = "<your_api_token>"
	sessionsURL = "https://resi-api.iproyal.com/v1/sessions"
)

func main() {
	data := map[string]interface{}{
		"residential_user_hashes": []string{"hash1", "hash2", "hash3"},
	}

	jsonData, err := json.Marshal(data)
	if err != nil {
		log.Fatal("Error marshaling JSON:", err)
	}

	req, err := http.NewRequest(http.MethodDelete, sessionsURL, bytes.NewBuffer(jsonData))
	if err != nil {
		log.Fatal("Error creating request:", err)
	}

	req.Header.Set("Authorization", "Bearer "+apiToken)
	req.Header.Set("Content-Type", "application/json")

	client := &http.Client{}
	resp, err := client.Do(req)
	if err != nil {
		log.Fatal("Error making request:", err)
	}
	defer resp.Body.Close()

	responseBody, err := io.ReadAll(resp.Body)
	if err != nil {
		log.Fatal("Error reading response body:", err)
	}
	
	fmt.Println(string(responseBody))
}
using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;

class Program
{
    static async Task Main(string[] args)
    {
        string apiToken = "<your_api_token>";
        string url = "https://resi-api.iproyal.com/v1/sessions";
        string[] residentialUserHashes = { "hash1", "hash2", "hash3" };

        var data = new
        {
            residential_user_hashes = residentialUserHashes
        };

        using (HttpClient client = new HttpClient())
        {
            client.DefaultRequestHeaders.Add("Authorization", $"Bearer {apiToken}");
            client.DefaultRequestHeaders.Add("Content-Type", "application/json");

            var jsonData = JsonConvert.SerializeObject(data);
            var content = new StringContent(jsonData, Encoding.UTF8, "application/json");

            HttpResponseMessage response = await client.DeleteAsync(url, content);

            string responseText = await response.Content.ReadAsStringAsync();
            Console.WriteLine(responseText);
        }
    }
}
PreviousAPINext用户

Last updated 2 months ago