用户
获取余额
GET
/balance
返回用户的余额。
响应案例:
curl -X GET "https://apid.iproyal.com/v1/reseller/balance" \
-H "X-Access-Token: <your_access_token>" \
-H "Content-Type: application/json"
<?php
$api_token = '<your_access_token>';
$url = "https://apid.iproyal.com/v1/reseller/balance";
$options = [
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => 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>'
url = 'https://apid.iproyal.com/v1/reseller/balance'
headers = {
'X-Access-Token': api_token,
'Content-Type': 'application/json'
}
response = requests.get(url, headers=headers)
print(response.status_code)
print(response.json())
const https = require('https');
const api_token = '<your_access_token>';
const options = {
hostname: 'apid.iproyal.com',
path: '/v1/reseller/balance',
method: 'GET',
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 urlString = "https://apid.iproyal.com/v1/reseller/balance";
try {
URL url = new URL(urlString);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("GET");
connection.setRequestProperty("X-Access-Token", apiToken);
connection.setRequestProperty("Content-Type", "application/json");
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("GET 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>"
url = "https://apid.iproyal.com/v1/reseller/balance"
)
func main() {
req, err := http.NewRequest(http.MethodGet, 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.Threading.Tasks;
using Newtonsoft.Json.Linq;
class Program
{
static async Task Main(string[] args)
{
string apiToken = "<your_access_token>";
string url = "https://apid.iproyal.com/v1/reseller/balance";
using (HttpClient client = new HttpClient())
{
client.DefaultRequestHeaders.Add("X-Access-Token", apiToken);
HttpResponseMessage response = await client.GetAsync(url);
Console.WriteLine((int)response.StatusCode);
string responseText = await response.Content.ReadAsStringAsync();
var jsonResponse = JObject.Parse(responseText);
Console.WriteLine(jsonResponse);
}
}
}
响应示例:
884.05
Last updated