增加计数器数值
将指定计数器的值增加指定数量(默认为 1)。需要有效的 api_key 和 counter_id。此接口会自动记录访问者的 IP 地址和地理位置。
请求参数
| 参数名 | 类型 | 必填 | 说明 |
action | string | 必填 | 固定值 increment |
api_key | string | 必填 | 您的 API Key |
counter_id | string | 必填 | 计数器 ID |
value | integer | 可选 | 增加的数值,默认为 1 |
GET 请求示例
# URL 格式(可在浏览器直接访问)
https://js.ruseo.cn/api/counter.php?action=increment&api_key=YOUR_API_KEY&counter_id=YOUR_COUNTER_ID&value=1
# curl 示例
curl -X GET "https://js.ruseo.cn/api/counter.php?action=increment&api_key=YOUR_API_KEY&counter_id=YOUR_COUNTER_ID&value=1"
POST 请求示例
# curl 示例 (JSON Body)
curl -X POST 'https://js.ruseo.cn/api/counter.php' \
-H 'Content-Type: application/json' \
-d '{
"action": "increment",
"api_key": "YOUR_API_KEY",
"counter_id": "YOUR_COUNTER_ID",
"value": 1
}'
# curl 示例 (Form Data)
curl -X POST 'https://js.ruseo.cn/api/counter.php' \
-d 'action=increment&api_key=YOUR_API_KEY&counter_id=YOUR_COUNTER_ID&value=1'
返回示例
// HTTP 200 OK
{
"success": true,
"message": "Counter incremented",
"value": 1
}
// HTTP 401
{
"error": "Invalid API key"
}
// HTTP 404
{
"error": "Counter not found"
}
// HTTP 403(账户或计数器被封禁)
{
"error": "Account banned",
"message": "您的账户已被封禁,如有问题请联系管理员。"
}
💻 多语言代码示例
以下示例演示如何调用 increment 接口
// JavaScript - Fetch API (GET)
fetch('https://js.ruseo.cn/api/counter.php?action=increment&api_key=YOUR_API_KEY&counter_id=YOUR_COUNTER_ID&value=1')
.then(res => res.json())
.then(data => {
if (data.success) {
console.log('计数增加成功,当前值:', data.value);
} else {
console.error('错误:', data.error);
}
})
.catch(err => console.error(err));
// JavaScript - Fetch API (POST + JSON)
fetch('https://js.ruseo.cn/api/counter.php', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
action: 'increment',
api_key: 'YOUR_API_KEY',
counter_id: 'YOUR_COUNTER_ID',
value: 1
})
});
// PHP - cURL GET 请求
$url = 'https://js.ruseo.cn/api/counter.php?action=increment&api_key=YOUR_API_KEY&counter_id=YOUR_COUNTER_ID&value=1';
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
$result = json_decode($response, true);
// PHP - cURL POST 请求 (JSON Body)
$data = [
'action' => 'increment',
'api_key' => 'YOUR_API_KEY',
'counter_id' => 'YOUR_COUNTER_ID',
'value' => 1
];
$ch = curl_init('https://js.ruseo.cn/api/counter.php');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = json_decode(curl_exec($ch), true);
# Python - requests GET
import requests
params = {
'action': 'increment',
'api_key': 'YOUR_API_KEY',
'counter_id': 'YOUR_COUNTER_ID',
'value': 1
}
response = requests.get('https://js.ruseo.cn/api/counter.php', params=params)
print(response.json())
# Python - requests POST
data = {
'action': 'increment',
'api_key': 'YOUR_API_KEY',
'counter_id': 'YOUR_COUNTER_ID',
'value': 1
}
response = requests.post(
'https://js.ruseo.cn/api/counter.php',
json=data # 自动添加 Content-Type: application/json
)
print(response.json())
// Java - HttpURLConnection
import java.net.*;
import java.io.*;
String urlStr = "https://js.ruseo.cn/api/counter.php?action=increment&api_key=YOUR_API_KEY&counter_id=YOUR_COUNTER_ID&value=1";
URL url = new URL(urlStr);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("GET");
BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
String inputLine;
StringBuilder response = new StringBuilder();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
System.out.println(response.toString());
// Go - net/http
package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://js.ruseo.cn/api/counter.php?action=increment&api_key=YOUR_API_KEY&counter_id=YOUR_COUNTER_ID&value=1"
resp, err := http.Get(url)
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}
获取计数器信息
查询指定计数器的当前数值、最后重置时间、最后计数时间等信息。
请求参数
| 参数名 | 类型 | 必填 | 说明 |
action | string | 必填 | 固定值 get |
api_key | string | 必填 | 您的 API Key |
counter_id | string | 必填 | 计数器 ID |
GET 请求示例
# URL 格式
https://js.ruseo.cn/api/counter.php?action=get&api_key=YOUR_API_KEY&counter_id=YOUR_COUNTER_ID
# curl 示例
curl -X GET "https://js.ruseo.cn/api/counter.php?action=get&api_key=YOUR_API_KEY&counter_id=YOUR_COUNTER_ID"
POST 请求示例
# curl 示例 (JSON Body)
curl -X POST 'https://js.ruseo.cn/api/counter.php' \
-H 'Content-Type: application/json' \
-d '{
"action": "get",
"api_key": "YOUR_API_KEY",
"counter_id": "YOUR_COUNTER_ID"
}'
返回示例
// HTTP 200 OK
{
"success": true,
"counter": {
"current_count": 1234,
"last_reset_time": "2024-01-15 10:30:00",
"last_count_time": "2024-01-20 15:45:00"
}
}
// HTTP 404
{
"error": "Counter not found"
}
// HTTP 401
{
"error": "Invalid API key"
}
重置计数器
将计数器数值重置为 0,并更新最后重置时间。此操作不可逆,请谨慎使用。
请求参数
| 参数名 | 类型 | 必填 | 说明 |
action | string | 必填 | 固定值 reset |
api_key | string | 必填 | 您的 API Key |
counter_id | string | 必填 | 计数器 ID |
GET 请求示例
# URL 格式(直接在浏览器访问即可重置)
https://js.ruseo.cn/api/counter.php?action=reset&api_key=YOUR_API_KEY&counter_id=YOUR_COUNTER_ID
# curl 示例
curl -X GET "https://js.ruseo.cn/api/counter.php?action=reset&api_key=YOUR_API_KEY&counter_id=YOUR_COUNTER_ID"
POST 请求示例
# curl 示例 (JSON Body)
curl -X POST 'https://js.ruseo.cn/api/counter.php' \
-H 'Content-Type: application/json' \
-d '{
"action": "reset",
"api_key": "YOUR_API_KEY",
"counter_id": "YOUR_COUNTER_ID"
}'
返回示例
// HTTP 200 OK
{
"success": true,
"message": "Counter reset"
}
// HTTP 404
{
"error": "Counter not found"
}
// HTTP 500
{
"error": "Database error"
}