إرسال ملف عبر الدردشة مع ruby on rails
إرسال ملف عن طريق الدردشة مع 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
# net/http library is required
require 'net/http'
afilnet_class="chat";
afilnet_method="sendfile";
afilnet_user="user";
afilnet_password="password";
afilnet_platform="whatsapp";
afilnet_platformid="100";
afilnet_destination="3460000000";
afilnet_type="image";
afilnet_fileurl="https://www.example.com/image.jpg";
afilnet_thumburl="https://www.example.com/thumb.jpg";
afilnet_message="test+message";
# Create an URL request
sUrl = "https://www.afilnet.com/api/http/?class="+afilnet_class+"&method="+afilnet_method+"&user="+afilnet_user+"&password="+afilnet_password+"&platform="+afilnet_platform+"&platformid="+afilnet_platformid+"&destination="+afilnet_destination+"&type="+afilnet_type+"&fileurl="+afilnet_fileurl+"&thumburl="+afilnet_thumburl+"&message="+afilnet_message;
uri = URI(sUrl)
response = Net::HTTP.get(uri)
# net/http library is required
require 'net/http'
afilnet_class="chat";
afilnet_method="sendfile";
afilnet_user="user";
afilnet_password="password";
afilnet_platform="whatsapp";
afilnet_platformid="100";
afilnet_destination="3460000000";
afilnet_type="image";
afilnet_fileurl="https://www.example.com/image.jpg";
afilnet_thumburl="https://www.example.com/thumb.jpg";
afilnet_message="test+message";
# 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, "platform" => afilnet_platform, "platformid" => afilnet_platformid, "destination" => afilnet_destination, "type" => afilnet_type, "fileurl" => afilnet_fileurl, "thumburl" => afilnet_thumburl, "message" => afilnet_message)
puts response.body
# net/http library is required
require 'net/http'
afilnet_class="chat";
afilnet_method="sendfile";
afilnet_user="user";
afilnet_password="password";
afilnet_platform="whatsapp";
afilnet_platformid="100";
afilnet_destination="3460000000";
afilnet_type="image";
afilnet_fileurl="https://www.example.com/image.jpg";
afilnet_thumburl="https://www.example.com/thumb.jpg";
afilnet_message="test+message";
# Create an URL request
sUrl = "https://www.afilnet.com/api/basic/?class="+afilnet_class+"&method="+afilnet_method+"&platform="+afilnet_platform+"&platformid="+afilnet_platformid+"&destination="+afilnet_destination+"&type="+afilnet_type+"&fileurl="+afilnet_fileurl+"&thumburl="+afilnet_thumburl+"&message="+afilnet_message;
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="chat";
afilnet_method="sendfile";
afilnet_user="user";
afilnet_password="password";
afilnet_platform="whatsapp";
afilnet_platformid="100";
afilnet_destination="3460000000";
afilnet_type="image";
afilnet_fileurl="https://www.example.com/image.jpg";
afilnet_thumburl="https://www.example.com/thumb.jpg";
afilnet_message="test+message";
# 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: "{\"platform\":\""+afilnet_platform+"\",\"platformid\":\""+afilnet_platformid+"\",\"destination\":\""+afilnet_destination+"\",\"type\":\""+afilnet_type+"\",\"fileurl\":\""+afilnet_fileurl+"\",\"thumburl\":\""+afilnet_thumburl+"\",\"message\":\""+afilnet_message+"\"}"
})
puts res.body
معامل | وصف | إجباري / اختياري |
---|---|---|
class=chat | الفئة المطلوبة: الفئة التي تم تقديم الطلب إليها | إلزامي |
method=sendfile | طريقة الفصل المطلوبة: طريقة الفصل الذي تم تقديم الطلب إليه | إلزامي |
user | المستخدم والبريد الإلكتروني لحساب Afilnet الخاص بك | إلزامي |
password | كلمة المرور لحساب Afilnet الخاص بك | إلزامي |
platform | المنصة التي يتم إرسال الرسالة إليها. القيم الممكنة: "webchat" و "whatsapp" و "telegram" و "المشغل" | إلزامي |
platformid | معرّف النظام الأساسي | إلزامي |
destination | المستلم حيث تم إرسال الملف | إلزامي |
type | نوع الملف المرسل. القيم المحتملة: "صورة" ، "فيديو" ، "صوت" ، "صوت" ، "مستند" ، "جهة اتصال" | إلزامي |
fileurl | عنوان Url حيث يوجد الملف المراد إرساله عن طريق الدردشة | إلزامي |
thumburl | عنوان URL للصورة المصغرة المصاحبة للملف | اختياري |
message | الرسالة المصاحبة للملف | اختياري |
عند تقديم طلبات ، ستتلقى الحقول التالية:
- status
-
النتيجة (إذا كانت الحالة = النجاح) ، سوف تتلقى هنا القيم التالية:
- لن يتم إرسال قيم إضافية إليك
- خطأ (إذا كانت الحالة = خطأ) ، هنا ستتلقى رمز الخطأ
يتم سرد رموز الأخطاء المحتملة أدناه
الشفرة | وصف |
---|---|
MISSING_USER | المستخدم أو البريد الإلكتروني غير المدرجة |
MISSING_PASSWORD | كلمة المرور غير المدرجة |
MISSING_CLASS | الطبقة غير المدرجة |
MISSING_METHOD | طريقة غير المدرجة |
MISSING_COMPULSORY_PARAM | المعلمة الإجبارية غير المدرجة |
INCORRECT_USER_PASSWORD | مستخدم غير صحيح أو كلمة المرور |
INCORRECT_CLASS | فئة غير صحيحة |
INCORRECT_METHOD | طريقة غير صحيحة |
CHANNEL_NOT_FOUND | القناة المشار إليها غير موجودة |
CHAT_NOT_FOUND | الدردشة المشار إليها غير موجودة |
INCORRECT_FILETYPE | نوع الملف خاطئ ، تحقق من القيم الممكنة |
INCORRECT_FILEURL | عنوان url للملف غير صالح |
INCORRECT_THUMBURL | عنوان url للصورة المصغرة غير صالح |
المعلمات:
- class : chat
- method : sendfile
- user : user
- password : password
- platform : whatsapp
- platformid : 100
- destination : 3460000000
- type : image
- fileurl : https://www.example.com/image.jpg
- thumburl : https://www.example.com/thumb.jpg
- message : test+message
طلب:
https://www.afilnet.com/api/http/?class=chat&method=sendfile&user=user&password=password&platform=whatsapp&platformid=100&destination=3460000000&type=image&fileurl=https://www.example.com/image.jpg&thumburl=https://www.example.com/thumb.jpg&message=test+message