This commit is contained in:
Hamza-Ayed
2024-09-15 09:53:40 +03:00
parent e23709c924
commit 9752d61230
24 changed files with 9002 additions and 221 deletions

View File

@@ -9,6 +9,7 @@ import 'package:SEFER/env/env.dart';
import '../../constant/api_key.dart';
import '../../print.dart';
import '../../views/widgets/elevated_btn.dart';
import 'upload_image.dart';
class CRUD {
@@ -71,6 +72,54 @@ class CRUD {
}
}
Future sendWhatsAppAuth(String to, String token) async {
var headers = {
'Authorization': 'Bearer ${Env.whatsapp}',
'Content-Type': 'application/json'
};
var request = http.Request(
'POST',
Uri.parse(
'https://graph.facebook.com/v20.0/${Env.whatappID}/messages'));
request.body = json.encode({
"messaging_product": "whatsapp",
"to": to, //"962798583052",
"type": "template",
"template": {
"name": "sefer1",
"language": {"code": "en"},
"components": [
{
"type": "body",
"parameters": [
{
"type": "text",
"text": token,
}
]
}
]
}
});
request.headers.addAll(headers);
http.StreamedResponse response = await request.send();
if (response.statusCode == 200) {
print(await response.stream.bytesToString());
Get.defaultDialog(
title: 'You will receive a code in WhatsApp Messenger'.tr,
middleText: '',
confirm: MyElevatedButton(
title: 'OK'.tr,
onPressed: () {
Get.back();
}));
} else {
print(response.reasonPhrase);
}
}
Future<dynamic> getAgoraToken({
required String channelName,
required String uid,