إرسال الرسائل القصيرة مع ruby on rails
إرسال الرسائل القصيرة باستخدام HTTP مع ruby on rails
ruby on rails : وثائق API
- إنشاء مجموعة باستخدام ruby on rails
- الحصول على قائمة حقول المجموعة باستخدام ruby on rails
- إضافة حقل إلى مجموعة بها ruby on rails
- حذف حقل من مجموعة بها ruby on rails
- حذف جهة اتصال من مجموعة
- عيّن البلد إلى مجموعة بها ruby on rails
- الحصول على قائمة جهات اتصال المجموعة باستخدام ruby on rails
- إضافة جهة اتصال إلى مجموعة بها ruby on rails
- تعديل جهة اتصال مجموعة بها ruby on rails
- حذف جهة اتصال لمجموعة بها ruby on rails
- احصل على قائمة بقنوات الدردشة النشطة باستخدام ruby on rails
- إرسال رسالة عبر الدردشة مع ruby on rails
- إرسال ملف عبر الدردشة مع ruby on rails
- احصل على قائمة المحادثات في دردشة مع ruby on rails
- الحصول على قائمة بالرسائل من دردشة مع ruby on rails
- احصل على قائمة بالرسائل غير المقروءة من دردشة مع ruby on rails
إرسال الرسائل القصيرة مع ruby on rails
Este método le permite enviar SMS a un destinatario utilizando ruby on rails. Enviar un SMS con ruby on rails es tan sencillo como enviar el origin, destino y el mensaje a enviar a través de una petición a nuestra API.
# net/http library is required
require 'net/http'
afilnet_class="sms";
afilnet_method="sendsms";
afilnet_user="user";
afilnet_password="password";
afilnet_from="Afilnet";
afilnet_to="34600000000";
afilnet_sms="sms+test";
afilnet_scheduledatetime="";
afilnet_output="";
# Create an URL request
sUrl = "https://www.afilnet.com/api/http/?class="+afilnet_class+"&method="+afilnet_method+"&user="+afilnet_user+"&password="+afilnet_password+"&from="+afilnet_from+"&to="+afilnet_to+"&sms="+afilnet_sms+"&scheduledatetime="+afilnet_scheduledatetime+"&output="+afilnet_output;
uri = URI(sUrl)
response = Net::HTTP.get(uri)
# net/http library is required
require 'net/http'
afilnet_class="sms";
afilnet_method="sendsms";
afilnet_user="user";
afilnet_password="password";
afilnet_from="Afilnet";
afilnet_to="34600000000";
afilnet_sms="sms+test";
afilnet_scheduledatetime="";
afilnet_output="";
# Create an URL request
sUrl = "https://www.afilnet.com/api/http/";
uri = URI(sUrl)
response = Net::HTTP.post_form(uri, "class" => afilnet_class, "method" => afilnet_method, "user" => afilnet_user, "password" => afilnet_password, "from" => afilnet_from, "to" => afilnet_to, "sms" => afilnet_sms, "scheduledatetime" => afilnet_scheduledatetime, "output" => afilnet_output)
puts response.body
# net/http library is required
require 'net/http'
afilnet_class="sms";
afilnet_method="sendsms";
afilnet_user="user";
afilnet_password="password";
afilnet_from="Afilnet";
afilnet_to="34600000000";
afilnet_sms="sms+test";
afilnet_scheduledatetime="";
afilnet_output="";
# Create an URL request
sUrl = "https://www.afilnet.com/api/basic/?class="+afilnet_class+"&method="+afilnet_method+"&from="+afilnet_from+"&to="+afilnet_to+"&sms="+afilnet_sms+"&scheduledatetime="+afilnet_scheduledatetime+"&output="+afilnet_output;
uri = URI(sUrl)
req = Net::HTTP::Get.new(uri)
req.basic_auth afilnet_user, afilnet_password
res = Net::HTTP.start(uri.hostname) {|http|
http.request(req)
}
puts res.body
# Savon library is required
require 'savon'
# We define vars
afilnet_class="sms";
afilnet_method="sendsms";
afilnet_user="user";
afilnet_password="password";
afilnet_from="Afilnet";
afilnet_to="34600000000";
afilnet_sms="sms+test";
afilnet_scheduledatetime="";
afilnet_output="";
# We create the client instance
client = Savon.client(wsdl: 'https://www.afilnet.com/api/soap/index.php?wsdl', ssl_verify_mode: :none)
# We call to the service
res = client.call(:call, message: {
user: afilnet_user,
password: afilnet_password,
class: afilnet_class,
method: afilnet_method,
petition: "{\"from\":\""+afilnet_from+"\",\"to\":\""+afilnet_to+"\",\"sms\":\""+afilnet_sms+"\",\"scheduledatetime\":\""+afilnet_scheduledatetime+"\",\"output\":\""+afilnet_output+"\"}"
})
puts res.body
معامل | وصف | إجباري / اختياري |
---|---|---|
class=sms | الفئة المطلوبة: الفئة التي تم تقديم الطلب إليها | إلزامي |
method=sendsms | طريقة الفصل المطلوبة: طريقة الفصل الذي تم تقديم الطلب إليه | إلزامي |
user | المستخدم والبريد الإلكتروني لحساب Afilnet الخاص بك | إلزامي |
password | كلمة المرور لحساب Afilnet الخاص بك | إلزامي |
from | مرسل | إلزامي |
to | رقم الهاتف المحمول للمستلم | إلزامي |
sms | رسالة نصية ليتم إرسالها | إلزامي |
scheduledatetime | إرسال التاريخ والوقت بتنسيق yyyy-mm-dd hh:mm:ss | اختياري |
output | تنسيق الإخراج من النتيجة | اختياري |
عند تقديم طلبات ، ستتلقى الحقول التالية:
- status
-
النتيجة (إذا كانت الحالة = النجاح) ، سوف تتلقى هنا القيم التالية:
- messageid
- credits
- خطأ (إذا كانت الحالة = خطأ) ، هنا ستتلقى رمز الخطأ
يتم سرد رموز الأخطاء المحتملة أدناه
الشفرة | وصف |
---|---|
MISSING_USER | المستخدم أو البريد الإلكتروني غير المدرجة |
MISSING_PASSWORD | كلمة المرور غير المدرجة |
MISSING_CLASS | الطبقة غير المدرجة |
MISSING_METHOD | طريقة غير المدرجة |
MISSING_COMPULSORY_PARAM | المعلمة الإجبارية غير المدرجة |
INCORRECT_USER_PASSWORD | مستخدم غير صحيح أو كلمة المرور |
INCORRECT_CLASS | فئة غير صحيحة |
INCORRECT_METHOD | طريقة غير صحيحة |
NO_ROUTE_AVAILABLE | لا توجد مسارات متاحة للوجهة المشار إليها |
NO_CREDITS | رصيدك غير كافٍ |
المعلمات:
- class : sms
- method : sendsms
- user : user
- password : password
- from : Afilnet
- to : 34600000000
- sms : sms+test
- scheduledatetime :
- output :
طلب:
https://www.afilnet.com/api/http/?class=sms&method=sendsms&user=user&password=password&from=Afilnet&to=34600000000&sms=sms+test&scheduledatetime=&output=