ارسال پیامک (SendSimple)

برای خرید سامانه پیامک همین الان در پیامک آموت ثبت نام کنید

متد وب سرویس ارسال پیامک (SendSimple)

آخرین بروزرسانی دوشنبه 6 دی 1400 12:21
Loading

متد SendSimple

از طریق این متد می توانید با وارد کردن متن و شماره ، پیامک های خود را به شماره یا شماره های انتخابی ارسال نمایید.

پارامترهای ورودی

Loading
نام نوع توضیحات
UserNameString الزامینام کاربری شما در سامانه پیامک آموت
PasswordString الزامیرمز عبور شما در سامانه پیامک آموت
SendDateTimeObject الزامیزمان ارسال پیامک
SMSMessageTextString الزامیمتن پیامک
LineNumberString الزامیشماره خط
MobilesObject الزامیلیست موبایل های دریافت کنندگان پیامک

مقدار خروجی

Loading
نام نوع توضیحات
ReturnValueObjectresult.Data شامل آرایه ای از یک کلاس با مقادیر
{
Status = وضعیت ,
MessageID = کد پیامک (کد شماره کمپین) ,
Mobile = شماره موبایل
}

نمونه کد

Loading
string UserName = "MyUserName";
string Password = "MyPassword";
DateTime SendDateTime = DateTime.Now;
string SMSMessageText = "پیامک تستی من";
string LineNumber = "public";
string[] Mobiles = new string[]
{
    "9120000000",
    "9150000000",
};

SMS.WebService2SoapClient client = new SMS.WebService2SoapClient("WebService2Soap12");

SMS.SendResult result = client.SendSimple(UserName, Password, SendDateTime, SMSMessageText, LineNumber, Mobiles);

if (result.Status == SMS.Status.Success)
{
    //خروجی
}
//result.Data => {Status,MessageID,Mobile},{Status,MessageID,Mobile},....
$url = "https://portal.amootsms.com/webservice2.asmx/SendSimple_REST";

$url = $url."?"."UserName=".urlencode("MyUserName");
$url = $url."&"."Password=".urlencode("MyPassword");

$nowIran = new DateTime('now', new DateTimeZone('IRAN'));
$url = $url."&"."SendDateTime=".urlencode($nowIran->format('c'));

$url = $url."&"."SMSMessageText=".urlencode("پیامک تستی من");
$url = $url."&"."LineNumber=public";

$url = $url."&"."Mobiles=9120000000,9150000000";

$json = file_get_contents($url);
echo $json;

//$result = json_decode($json);
//echo $result->Status;
ini_set("soap.wsdl_cache_enabled", "0");

$sms_client = new SoapClient('https://portal.amootsms.com/webservice2.asmx?wsdl', array('encoding'=>'UTF-8'));

$parameters['UserName'] = "MyUserName";
$parameters['Password'] = "MyPassword";

$nowIran = new DateTime('now', new DateTimeZone('IRAN'));
$parameters['SendDateTime'] = $nowIran->format('c');

$parameters['SMSMessageText'] = "پیامک تستی من";
$parameters['LineNumber'] = "public";
$parameters['Mobiles'] =array("9120000000", "9150000000");

$result = $sms_client->SendSimple($parameters)->SendSimpleResult;
echo $result;
///////////// Method GET =>

const https = require('https');

var url = 'https://portal.amootsms.com/webservice2.asmx/SendSimple_REST';
url += '?UserName='+encodeURIComponent('MyUserName');
url += '&Password='+encodeURIComponent('MyPassword');
url += '&SendDateTime=2020-01-01 12:00:00';
url += '&SMSMessageText='+encodeURIComponent('تست');
url += '&LineNumber=public';
url += '&Mobiles=09159999999,09129999999';


https.get(url, (resp) => {
    let data = '';

    // A chunk of data has been received.
    resp.on('data', (chunk) => {
        data += chunk;
    });

    // The whole response has been received. Print out the result.
    resp.on('end', () => {
        console.log(JSON.parse(data).explanation);
    });

}).on("error", (err) => {
    console.log("Error: " + err.message);
});


/////////// Method POST =>


const https = require('https');

var postData = JSON.stringify({
    'UserName': 'MyUserName',
    'Password': 'MyPassword',
    'SendDateTime': '2020-01-01 12:00:00',
    'SMSMessageText': 'تست',
    'LineNumber': 'public',
    'Mobiles': '09159999999,09129999999'
});

var options = {
    hostname: 'portal.amootsms.com',
    port: 443,
    path: '/webservice2.asmx/SendSimple_REST',
    method: 'POST',
    headers: {
        'Content-Type': 'application/x-www-form-urlencoded',
        'Content-Length': postData.length
    }
};

var req = https.request(options, (resp) => {
    console.log('statusCode:', resp.statusCode);
    console.log('headers:', resp.headers);

    let data = '';

    // A chunk of data has been received.
    resp.on('data', (chunk) => {
        data += chunk;
    });

    // The whole response has been received. Print out the result.
    resp.on('end', () => {
        console.log(JSON.parse(data).explanation);
    });
});

req.on('error', (e) => {
    console.error(e);
});

req.write(postData);
req.end();