-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi7.php
More file actions
132 lines (113 loc) · 3.74 KB
/
api7.php
File metadata and controls
132 lines (113 loc) · 3.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
<?php
/**
* QuizGiri API Wrapper with Phone Number Support
* Endpoint: /api/v2.0/send-otp
* Creator: @SABBIRX007
*/
// Set response headers
header('Content-Type: application/json');
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET, POST');
header('Access-Control-Allow-Headers: Content-Type');
// Creator information
$creator = "@SABBIRX007";
// Check if phone parameter is provided
if (!isset($_GET['phone']) || empty($_GET['phone'])) {
http_response_code(400);
echo json_encode([
'success' => false,
'message' => 'Please provide a phone number. Usage: api6.php?phone=01700000000',
'creator' => $creator
], JSON_PRETTY_PRINT);
exit;
}
// Get and validate phone number
$phone = trim($_GET['phone']);
// Remove any non-numeric characters
$phone = preg_replace('/[^0-9]/', '', $phone);
// Validate Bangladeshi phone number (11 digits starting with 01)
if (strlen($phone) !== 11 || !preg_match('/^01[3-9]\d{8}$/', $phone)) {
http_response_code(400);
echo json_encode([
'success' => false,
'message' => 'Invalid phone number. Please provide a valid 11-digit Bangladeshi number (e.g., 01710158899)',
'creator' => $creator
], JSON_PRETTY_PRINT);
exit;
}
// Add Bangladesh country code
$country_code = "+88";
$full_phone = $country_code . $phone;
// Initialize cURL
$curl = curl_init();
// Prepare request data
$post_data = json_encode([
'country_code' => $country_code,
'phone' => $full_phone
]);
// Set cURL options
curl_setopt_array($curl, [
CURLOPT_URL => 'https://developer.quizgiri.xyz/api/v2.0/send-otp',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => $post_data,
CURLOPT_HTTPHEADER => [
'User-Agent: Mozilla/5.0 (Linux; Android 14; CPH2381 Build/UKQ1.230924.001) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.6778.260 Mobile Safari/537.36',
'Accept-Encoding: gzip, deflate, br, zstd',
'Content-Type: application/json',
'sec-ch-ua-platform: "Android"',
'Authorization: Bearer',
'sec-ch-ua: "Android WebView";v="131", "Chromium";v="131", "Not_A Brand";v="24"',
'sec-ch-ua-mobile: ?1',
'Origin: https://app.quizgiri.com.bd',
'X-Requested-With: com.xbrowser.play',
'Sec-Fetch-Site: cross-site',
'Sec-Fetch-Mode: cors',
'Sec-Fetch-Dest: empty',
'Referer: https://app.quizgiri.com.bd/',
'Accept-Language: en-BD,en-US;q=0.9,en;q=0.8',
'Content-Length: ' . strlen($post_data)
],
]);
// Execute cURL request
$response = curl_exec($curl);
$http_code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
$err = curl_error($curl);
// Close cURL for PHP versions < 8.0.5
if (PHP_VERSION_ID < 80500) {
curl_close($curl);
}
// Handle cURL errors
if ($err) {
http_response_code(500);
echo json_encode([
'success' => false,
'http_code' => $http_code,
'message' => 'cURL Error: ' . $err,
'creator' => $creator
], JSON_PRETTY_PRINT);
exit;
}
// Decode the API response
$decoded_response = json_decode($response, true);
// Prepare success response
$success_response = [
'success' => ($http_code >= 200 && $http_code < 300),
'http_code' => $http_code,
'data' => $decoded_response ?: $response,
'message' => 'Response received successfully',
'creator' => $creator
];
// Set HTTP status code based on API response
http_response_code($http_code);
// Output the response
echo json_encode($success_response, JSON_PRETTY_PRINT);
// Close cURL for PHP versions >= 8.0.5
if (PHP_VERSION_ID >= 80500) {
curl_close($curl);
}
?>