✅ تأیید توکن و دریافت اطلاعات کاربر
پس از بازگشت کاربر به redirect_uri، توکن در پارامتر ?token=... قرار دارد. آن را با یک درخواست POST به آدرس زیر تأیید کنید:
POST https://nooty.ir/account/account.php?action=verify-token
Content-Type: application/x-www-form-urlencoded
token=ABC123...
پاسخ موفق (200 OK)
{
"success": true,
"user": {
"id": 5,
"email": "user@example.com",
"username": "username",
"display_name": "نام کاربر",
"wallet_balance": "100.00",
"is_admin": 0
}
}
پاسخ ناموفق
{ "success": false }
توکنها یکبار مصرف هستند و فقط ۳۰ ثانیه اعتبار دارند. پس از اولین تأیید، منقضی میشوند.
نمونه کد به زبانهای مختلف
<?php
$token = $_GET['token'];
$ch = curl_init('https://nooty.ir/account/account.php?action=verify-token');
curl_setopt_array($ch, [
CURLOPT_POST => 1,
CURLOPT_POSTFIELDS => http_build_query(['token' => $token]),
CURLOPT_RETURNTRANSFER => true
]);
$response = curl_exec($ch);
curl_close($ch);
$data = json_decode($response, true);
if ($data['success']) {
echo 'خوش آمدید ' . htmlspecialchars($data['user']['display_name']);
}
?>const token = new URLSearchParams(window.location.search).get('token');
fetch('https://nooty.ir/account/account.php?action=verify-token', {
method: 'POST',
headers: {'Content-Type': 'application/x-www-form-urlencoded'},
body: 'token=' + encodeURIComponent(token)
})
.then(res => res.json())
.then(data => {
if (data.success) console.log('سلام ' + data.user.display_name);
});import requests
from urllib.parse import urlencode
token = request.args.get('token')
resp = requests.post(
'https://nooty.ir/account/account.php?action=verify-token',
data=urlencode({'token': token}),
headers={'Content-Type': 'application/x-www-form-urlencoded'}
)
data = resp.json()
if data['success']:
print(f"خوش آمدید {data['user']['display_name']}")const axios = require('axios');
const qs = require('qs');
const token = req.query.token;
axios.post('https://nooty.ir/account/account.php?action=verify-token',
qs.stringify({ token })
).then(response => {
if (response.data.success) console.log('سلام ' + response.data.user.display_name);
});curl -X POST \
'https://nooty.ir/account/account.php?action=verify-token' \
-d 'token=YOUR_TOKEN'using var client = new HttpClient();
var content = new FormUrlEncodedContent(new[] {
new KeyValuePair<string, string>("token", token)
});
var response = await client.PostAsync("https://nooty.ir/account/account.php?action=verify-token", content);
var json = await response.Content.ReadAsStringAsync();
// parse jsonHttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://nooty.ir/account/account.php?action=verify-token"))
.header("Content-Type", "application/x-www-form-urlencoded")
.POST(HttpRequest.BodyPublishers.ofString("token=" + URLEncoder.encode(token, StandardCharsets.UTF_8)))
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
// parse JSONimport "net/url"
data := url.Values{"token": {token}}
resp, _ := http.PostForm("https://nooty.ir/account/account.php?action=verify-token", data)
defer resp.Body.Close()
// decode JSONrequire 'net/http'
require 'uri'
uri = URI('https://nooty.ir/account/account.php?action=verify-token')
res = Net::HTTP.post_form(uri, 'token' => token)
data = JSON.parse(res.body)
puts "سلام #{data['user']['display_name']}" if data['success']🚀 برای شروع برنامه خود را ثبت کنید.
🔐 ورود با NootyAccount