This commit is contained in:
Hamza-Ayed
2024-02-04 23:53:13 +03:00
parent 87da645ae5
commit 481eff94c2
24 changed files with 708 additions and 332 deletions

View File

@@ -209,6 +209,61 @@ class CRUD {
}
}
Future<void> sendVerificationRequest(String phoneNumber) async {
final accountSid = "ACb4ad857efe0903bfd6238a763a2ce4d1";
final authToken = "14f39ef4628bb8a4f18469f462f8af75";
final verifySid = "VAf6e6022a7e95186aa5b1da25411859bd";
final Uri verificationUri = Uri.parse(
'https://verify.twilio.com/v2/Services/$verifySid/Verifications');
// Send the verification request
final response = await http.post(
verificationUri,
headers: {
'Authorization':
'Basic ' + base64Encode(utf8.encode('$accountSid:$authToken')),
'Content-Type': 'application/x-www-form-urlencoded',
},
body: {
'To': phoneNumber,
'Channel': 'sms',
},
);
if (response.statusCode == 201) {
print('Verification request sent');
} else {
print('Failed to send verification request');
}
// Prompt the user to enter the OTP
final otpCode = "123456"; // Replace with user input
// Check the verification code
final checkUri = Uri.parse(
'https://verify.twilio.com/v2/Services/$verifySid/VerificationCheck');
final checkResponse = await http.post(
checkUri,
headers: {
'Authorization':
'Basic ' + base64Encode(utf8.encode('$accountSid:$authToken')),
'Content-Type': 'application/x-www-form-urlencoded',
},
body: {
'To': phoneNumber,
'Code': otpCode,
},
);
if (checkResponse.statusCode == 201) {
print('Verification successful');
} else {
print('Verification failed');
}
}
Future<dynamic> getGoogleApi({
required String link,
Map<String, dynamic>? payload,
@@ -220,7 +275,7 @@ class CRUD {
url,
body: payload,
);
//print(response.request);
print(response.request);
var jsonData = jsonDecode(response.body);
// //print(jsonData);
if (jsonData['status'] == 'OK') {