代理
Last updated
Last updated
POST
/4g/rotate-ip/{key}
查询参数
名称 | 类型 | 描述 |
---|---|---|
响应案例:
curl -X POST "https://apid.iproyal.com/v1/reseller/4g/rotate-ip/<your_key>" \
-H "X-Access-Token: <your_access_token>" \
-H "Content-Type: application/json"
<?php
$api_token = '<your_access_token>';
$key = '<your_key>';
$url = "https://apid.iproyal.com/v1/reseller/4g/rotate-ip/$key";
$options = [
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => [
"X-Access-Token: $api_token",
'Content-Type: application/json'
]
];
$ch = curl_init();
curl_setopt_array($ch, $options);
$response = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
} else {
echo $response;
}
curl_close($ch);
?>
import requests
api_token = '<your_access_token>'
key = '<your_key>'
url = f'https://apid.iproyal.com/v1/reseller/4g/rotate-ip/{key}'
headers = {
'X-Access-Token': api_token,
'Content-Type': 'application/json'
}
response = requests.post(url, headers=headers)
print(response.status_code)
print(response.json())
const https = require('https');
const api_token = '<your_access_token>';
const key = '<your_key>';
const options = {
hostname: 'apid.iproyal.com',
path: `/v1/reseller/4g/rotate-ip/${key}`,
method: 'POST',
headers: {
'X-Access-Token': api_token,
'Content-Type': 'application/json'
}
};
const req = https.request(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.end();
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
public class ApiRequest {
public static void main(String[] args) {
String apiToken = "<your_access_token>";
String key = "<your_key>";
String urlString = String.format("https://apid.iproyal.com/v1/reseller/4g/rotate-ip/%s", key);
try {
URL url = new URL(urlString);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("POST");
connection.setRequestProperty("X-Access-Token", apiToken);
connection.setRequestProperty("Content-Type", "application/json");
connection.setDoOutput(true);
int responseCode = connection.getResponseCode();
System.out.println("Response Code: " + responseCode);
if (responseCode == HttpURLConnection.HTTP_OK) {
BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
String inputLine;
StringBuilder content = new StringBuilder();
while ((inputLine = in.readLine()) != null) {
content.append(inputLine);
}
in.close();
System.out.println("Response Body: " + content.toString());
} else {
System.out.println("Post request failed. Response Code: " + responseCode);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
package main
import (
"encoding/json"
"fmt"
"io"
"log"
"net/http"
)
const (
apiToken = "<your_access_token>"
key = "<your_key>"
)
func main() {
url := fmt.Sprintf("https://apid.iproyal.com/v1/reseller/4g/rotate-ip/%s", key)
req, err := http.NewRequest(http.MethodPost, url, nil)
if err != nil {
log.Fatal("Error creating request:", err)
}
req.Header.Set("X-Access-Token", 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()
fmt.Println("Status Code:", resp.StatusCode)
responseBody, err := io.ReadAll(resp.Body)
if err != nil {
log.Fatal("Error reading response body:", err)
}
var jsonResponse map[string]interface{}
err = json.Unmarshal(responseBody, &jsonResponse)
if err != nil {
log.Fatal("Error unmarshaling JSON:", err)
}
fmt.Printf("%+v\n", jsonResponse)
}
using System;
using System.Net.Http;
using System.Text.Json;
using System.Threading.Tasks;
class Program
{
static async Task Main(string[] args)
{
string apiToken = "<your_access_token>";
string key = "<your_key>";
string url = $"https://apid.iproyal.com/v1/reseller/4g/rotate-ip/{key}";
using (HttpClient client = new HttpClient())
{
client.DefaultRequestHeaders.Add("X-Access-Token", apiToken);
HttpResponseMessage response = await client.PostAsync(url);
Console.WriteLine((int)response.StatusCode);
string responseText = await response.Content.ReadAsStringAsync();
var jsonResponse = JsonSerializer.Deserialize<JsonElement>(responseText);
Console.WriteLine(jsonResponse);
}
}
}
key
字符串
轮换IP的键