إرسال رسائل نصية مجمعة مع Android
إرسال رسائل نصية مجمعة إلى مجموعة من جهات الاتصال مع Android
Android : وثائق API
- إنشاء مجموعة باستخدام Android
- الحصول على قائمة حقول المجموعة باستخدام Android
- إضافة حقل إلى مجموعة بها Android
- حذف حقل من مجموعة بها Android
- حذف جهة اتصال من مجموعة
- عيّن البلد إلى مجموعة بها Android
- الحصول على قائمة جهات اتصال المجموعة باستخدام Android
- إضافة جهة اتصال إلى مجموعة بها Android
- تعديل جهة اتصال مجموعة بها Android
- حذف جهة اتصال لمجموعة بها Android
إرسال رسائل نصية مجمعة مع Android
Con este método puede enviar con Android campañas de SMS Masivo a grupos de contactos que haya creado. Incluya el grupo, el prefijo del país, el remitente, el SMS a enviar. Este método le permite enviar campañas de SMS Masivo sin limite de destinatarios con Android.
String afilnet_class="sms";
String afilnet_method="sendsmstogroup";
String afilnet_user="user";
String afilnet_password="password";
String afilnet_from="Afilnet";
String afilnet_countrycode="34";
String afilnet_idgroup="1";
String afilnet_sms="sms+test";
String afilnet_scheduledatetime="";
String afilnet_output="";
// Create an URL request
String sUrl = "https://www.afilnet.com/api/http/?class="+afilnet_class+"&method="+afilnet_method+"&user="+afilnet_user+"&password="+afilnet_password+"&from="+afilnet_from+"&countrycode="+afilnet_countrycode+"&idgroup="+afilnet_idgroup+"&sms="+afilnet_sms+"&scheduledatetime="+afilnet_scheduledatetime+"&output="+afilnet_output;
URL url = new URL(sUrl);
StringBuilder builder = new StringBuilder();
BufferedReader theJSONline = new BufferedReader(new InputStreamReader(url.openStream()));
builder.append(theJSONline.readLine());
String content = builder.toString();
String afilnet_class="sms";
String afilnet_method="sendsmstogroup";
String afilnet_user="user";
String afilnet_password="password";
String afilnet_from="Afilnet";
String afilnet_countrycode="34";
String afilnet_idgroup="1";
String afilnet_sms="sms+test";
String afilnet_scheduledatetime="";
String afilnet_output="";
// Create the POST request
String post = "class="+afilnet_class+"&method="+afilnet_method+"&user="+afilnet_user+"&password="+afilnet_password+"&from="+afilnet_from+"&countrycode="+afilnet_countrycode+"&idgroup="+afilnet_idgroup+"&sms="+afilnet_sms+"&scheduledatetime="+afilnet_scheduledatetime+"&output="+afilnet_output;
// We generate the URL
URL myurl = new URL("https://www.afilnet.com/api/http/");
// We create the connection
HttpURLConnection con = (HttpURLConnection) myurl.openConnection();
con.setDoOutput(true);
con.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
con.setRequestProperty("Content-Length", String.valueOf(post.length()));
con.setRequestMethod("POST");
// We build the
OutputStream os = con.getOutputStream();
os.write(post.getBytes());
os.close();
StringBuilder sb = new StringBuilder();
int HttpResult = con.getResponseCode();
if(HttpResult == HttpURLConnection.HTTP_OK)
{
BufferedReader br = new BufferedReader(new InputStreamReader(con.getInputStream(),"utf-8"));
String line = null;
while ((line = br.readLine()) != null) {
sb.append(line + "\n");
}
br.close();
System.out.println(""+sb.toString());
} else {
System.out.println(con.getResponseCode());
System.out.println(con.getResponseMessage());
}
String afilnet_class="sms";
String afilnet_method="sendsmstogroup";
String afilnet_user="user";
String afilnet_password="password";
String afilnet_from="Afilnet";
String afilnet_countrycode="34";
String afilnet_idgroup="1";
String afilnet_sms="sms+test";
String afilnet_scheduledatetime="";
String afilnet_output="";
// Create the POST request
String post = "class="+afilnet_class+"&method="+afilnet_method+"&from="+afilnet_from+"&countrycode="+afilnet_countrycode+"&idgroup="+afilnet_idgroup+"&sms="+afilnet_sms+"&scheduledatetime="+afilnet_scheduledatetime+"&output="+afilnet_output;
// We generate the URL
URL myurl = new URL("https://www.afilnet.com/api/basic/");
// We create the connection
HttpURLConnection con = (HttpURLConnection) myurl.openConnection();
String encoded = Base64.getEncoder().encodeToString((afilnet_user+":"+afilnet_password).getBytes(StandardCharsets.UTF_8));
con.setRequestProperty("Authorization", "Basic "+encoded);
con.setDoOutput(true);
con.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
con.setRequestProperty("Content-Length", String.valueOf(post.length()));
con.setRequestMethod("POST");
// We build the
OutputStream os = con.getOutputStream();
os.write(post.getBytes());
os.close();
StringBuilder sb = new StringBuilder();
int HttpResult = con.getResponseCode();
if(HttpResult == HttpURLConnection.HTTP_OK)
{
BufferedReader br = new BufferedReader(new InputStreamReader(con.getInputStream(),"utf-8"));
String line = null;
while ((line = br.readLine()) != null) {
sb.append(line + "\n");
}
br.close();
System.out.println(""+sb.toString());
} else {
System.out.println(con.getResponseCode());
System.out.println(con.getResponseMessage());
}
معامل | وصف | إجباري / اختياري |
---|---|---|
class=sms | الفئة المطلوبة: الفئة التي تم تقديم الطلب إليها | إلزامي |
method=sendsmstogroup | طريقة الفصل المطلوبة: طريقة الفصل الذي تم تقديم الطلب إليه | إلزامي |
user | المستخدم والبريد الإلكتروني لحساب Afilnet الخاص بك | إلزامي |
password | كلمة المرور لحساب Afilnet الخاص بك | إلزامي |
from | مرسل | إلزامي |
countrycode | رمز الاتصال بالدولة | إلزامي |
idgroup | معرف مجموعة المستلم | إلزامي |
sms | رسالة نصية ليتم إرسالها | إلزامي |
scheduledatetime | تاريخ ووقت التسليم بتنسيق yyyy-mm-dd hh:mm:ss | اختياري |
output | تنسيق الإخراج من النتيجة | اختياري |
عند تقديم طلبات ، ستتلقى الحقول التالية:
- status
-
النتيجة (إذا كانت الحالة = النجاح) ، سوف تتلقى هنا القيم التالية:
- id
- count
- credits
-
destinations
- messageid
- destination
- خطأ (إذا كانت الحالة = خطأ) ، هنا ستتلقى رمز الخطأ
يتم سرد رموز الأخطاء المحتملة أدناه
الشفرة | وصف |
---|---|
MISSING_USER | المستخدم أو البريد الإلكتروني غير المدرجة |
MISSING_PASSWORD | كلمة المرور غير المدرجة |
MISSING_CLASS | الطبقة غير المدرجة |
MISSING_METHOD | طريقة غير المدرجة |
MISSING_COMPULSORY_PARAM | المعلمة الإجبارية غير المدرجة |
INCORRECT_USER_PASSWORD | مستخدم غير صحيح أو كلمة المرور |
INCORRECT_CLASS | فئة غير صحيحة |
INCORRECT_METHOD | طريقة غير صحيحة |
NOT_ACCESS_TO_GROUP | غير مسموح لك بالدخول إلى المجموعة المشار إليها |
NO_CREDITS | رصيدك غير كافٍ |
المعلمات:
- class : sms
- method : sendsmstogroup
- user : user
- password : password
- from : Afilnet
- countrycode : 34
- idgroup : 1
- sms : sms+test
- scheduledatetime :
- output :
طلب:
https://www.afilnet.com/api/http/?class=sms&method=sendsmstogroup&user=user&password=password&from=Afilnet&countrycode=34&idgroup=1&sms=sms+test&scheduledatetime=&output=