import requests
import time
BASE_URL = "http://qn.ios163.com:5689"
API_KEY = "YOUR_API_KEY"
def get_phone_number(country, service):
url = f"{BASE_URL}/get_phone"
headers = {
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json"
}
data = {"country": country, "service": service}
response = requests.post(url, headers=headers, json=data)
if response.status_code == 200:
result = response.json()
if result.get("success"):
return result["phone"], result["id"]
return None, None
def get_sms_code(order_id, max_attempts=10):
url = f"{BASE_URL}/get_sms"
headers = {
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json"
}
data = {"id": order_id}
for _ in range(max_attempts):
response = requests.post(url, headers=headers, json=data)
if response.status_code == 200:
result = response.json()
if result.get("success") and result.get("sms"):
return result["sms"]
time.sleep(10)
return None
if __name__ == "__main__":
phone, order_id = get_phone_number("usa", "TG")
if phone:
print(f"获取号码: {phone}, 订单ID: {order_id}")
sms = get_sms_code(order_id)
if sms:
print(f"收到短信: {sms}")
if "验证码" in sms:
code = sms.split(":")[-1].strip()
print(f"验证码: {code}")
else:
print("未收到短信")
else:
print("获取号码失败")
const BASE_URL = "http://qn.ios163.com:5000";
const API_KEY = "YOUR_API_KEY";
async function getPhoneNumber(country, service) {
const url = `${BASE_URL}/get_phone`;
const response = await fetch(url, {
method: 'POST',
headers: {
'Authorization': `Bearer ${API_KEY}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({ country, service })
});
const data = await response.json();
if (data.success) {
return { phone: data.phone, id: data.id };
}
return null;
}
async function getSMSCode(orderId, maxAttempts = 10) {
const url = `${BASE_URL}/get_sms`;
for (let attempt = 0; attempt < maxAttempts; attempt++) {
const response = await fetch(url, {
method: 'POST',
headers: {
'Authorization': `Bearer ${API_KEY}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({ id: orderId })
});
const data = await response.json();
if (data.success && data.sms) {
return data.sms;
}
await new Promise(resolve => setTimeout(resolve, 10000));
}
return null;
}
(async () => {
const phoneData = await getPhoneNumber("usa", "TG");
if (phoneData) {
console.log(`获取号码: ${phoneData.phone}, 订单ID: ${phoneData.id}`);
const sms = await getSMSCode(phoneData.id);
if (sms) {
console.log(`收到短信: ${sms}`);
if (sms.includes("验证码")) {
const code = sms.split(":")[1].trim();
console.log(`验证码: ${code}`);
}
} else {
console.log("未收到短信");
}
} else {
console.log("获取号码失败");
}
})();
<?php
$baseUrl = "http://qn.ios163.com:5000";
$apiKey = "YOUR_API_KEY";
function getPhoneNumber($country, $service) {
global $baseUrl, $apiKey;
$url = $baseUrl . "/get_phone";
$data = [
"country" => $country,
"service" => $service
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Authorization: Bearer $apiKey",
"Content-Type: application/json"
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($httpCode === 200) {
$result = json_decode($response, true);
if ($result["success"]) {
return [$result["phone"], $result["id"]];
}
}
return [null, null];
}
function getSMSCode($orderId, $maxAttempts = 10) {
global $baseUrl, $apiKey;
$url = $baseUrl . "/get_sms";
$data = ["id" => $orderId];
for ($i = 0; $i < $maxAttempts; $i++) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Authorization: Bearer $apiKey",
"Content-Type: application/json"
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($httpCode === 200) {
$result = json_decode($response, true);
if ($result["success"] && $result["sms"]) {
return $result["sms"];
}
}
sleep(10);
}
return null;
}
list($phone, $orderId) = getPhoneNumber("usa", "TG");
if ($phone) {
echo "获取号码: $phone, 订单ID: $orderId\n";
$sms = getSMSCode($orderId);
if ($sms) {
echo "收到短信: $sms\n";
if (strpos($sms, "验证码") !== false) {
$parts = explode(":", $sms);
$code = trim(end($parts));
echo "验证码: $code\n";
}
} else {
echo "未收到短信\n";
}
} else {
echo "获取号码失败\n";
}
?>