This document provides instructions for integrating the eBDSMS Android SDK into your project.
How to use ?
To get a Git project into your build:
Step 1. Add the JitPack repository to your build file
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
Step 2. Add the dependency to your
build.gradle
:
dependencies {
implementation 'com.github.ebdsms:eBDSMS:2.0.4'
}
Add the following code inside your Activity
:
private static String API_KEY = "YOUR_API_KEY";
private static String DEVICE_NUMBER = "DEVICE_NUMBER";
private static String NUMBER = "SEND_NUMBER";
private static String MESSAGE = "MESSAGE";
Note: Use this code send otp:
// If you want to send OTP then use this 2 line code, or skip this 2 line code.
eBDSMS.OTP otp = new eBDSMS.OTP();
String otpString = otp.OTPString(6); // Enter the value of the number you want to send OTP like 4,6
Note: Use this code when the sms send button is clicked:
eBDSMS sms = new eBDSMS(API_KEY,DEVICE_NUMBER,NUMBER,MESSAGE+" "+otpString,null,null);
sms.sendSms(this);
This document provides instructions for integrating the eBDSMS Flutter project.
How to use ?
dependencies:
flutter:
sdk: flutter
http: ^0.14.0 # Make sure to use the latest version
Create eBDSMS Class.
import 'dart:math';
import 'package:http/http.dart' as http;
class eBDSMS {
String apiKey;
String number;
String message;
String device;
String extra;
String others;
eBDSMS({
required this.apiKey,
required this.number,
required this.message,
required this.device,
required this.extra,
required this.others,
});
Future<String> sendSms() async {
try {
String baseUrl = "https://client.ebdsms.com/services/send.php";
Uri url = Uri.parse(
"$baseUrl?key=$apiKey&number=$number&message=$message&devices=$device&type=sms&prioritize=0");
final response = await http.get(url);
if (response.statusCode == 200) {
return response.body;
} else {
return 'Error: ${response.statusCode}';
}
} catch (e) {
print(e);
return 'Error: $e';
}
}
}
class OTP {
final String letters = "0987654321";
final String numbers = "1234567890";
late List<String> randomChars;
OTP() {
randomChars = (letters + letters.toUpperCase() + numbers).split('');
}
String generateOTP(int length) {
final random = Random();
return List.generate(length, (_) => randomChars[random.nextInt(randomChars.length)]).join();
}
}
void main() async {
String apiKey = "YOUR_API_KEY";
String deviceNumber = "DEVICE_NUMBER";
String number = "SEND_NUMBER";
String message = "MESSAGE";
// Generate OTP
OTP otp = OTP();
String otpString = otp.generateOTP(6);
print("Generated OTP: $otpString");
// Create eBDSMS instance with the message + OTP
eBDSMS sms = eBDSMS(
apiKey: apiKey,
number: number,
message: "$message $otpString",
device: deviceNumber,
extra: '',
others: '',
);
// Send SMS
String response = await sms.sendSms();
print("SMS Response: $response");
}
dart
void main() {
EBDSMS sms = EBDSMS(
apiKey: 'your_api_key',
number: 'recipient_number',
message: 'Hello, this is your message!',
otp: '1234',
device: 'device_id',
extra: 'extra_info',
);
sms.sendSms();
}
If you face any problem using this library then feel free to contact me. To contact me message me on Facebook or email me at:
Email
: info@ebdsms.com
Facebook
: Shohag Hossain