Skip to content

Instantly share code, notes, and snippets.

@mahdyar
Created August 21, 2022 12:04
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mahdyar/183db674a46d69755494a5d948bcafaa to your computer and use it in GitHub Desktop.
Save mahdyar/183db674a46d69755494a5d948bcafaa to your computer and use it in GitHub Desktop.
سرویس سامانه پیامکی آسیاتک برای افزونه پیام کوتاه WHMCS وهاب آنلاین
<?php
/*
*
*
*
* Developed by Mahdyar.me
* Contact: hi@mahdyar.me
*
*
*
*/
define('SEND_URI', 'https://smsapi.asiatech.ir/api/message/send');
define('PROXY', '');
function info_asiatech()
{
return array(
"name" => "آسیاتک",
"username_label" => "نام کاربری",
"password_label" => "رمز عبور",
"sendernumber_label" => "شماره ارسال کننده",
"pattern_label" => false,
"pattern" => true,
);
}
function status_asiatech($username, $password, $smsNumber)
{
$postFields = array([
"SourceAddress" => $smsNumber,
"MessageText" => 'تست ارسال پیامک',
"DestinationAddress" => ''
]);
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => SEND_URI,
CURLOPT_PROXY => PROXY,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => json_encode($postFields),
CURLOPT_HTTPHEADER => array(
'Authorization: Basic ' . base64_encode("$username:$password"),
'Content-Type: application/json'
),
));
$response = curl_exec($curl);
curl_close($curl);
$response = json_decode($response);
if ($response->succeeded == true)
return true;
return false;
}
function balance_asiatech($username, $password, $smsNumber)
{
$balanceURI = 'https://smsapi.asiatech.ir/api/user/userinfo';
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => $balanceURI,
CURLOPT_PROXY => PROXY,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_HTTPHEADER => array(
'Authorization: Basic ' . base64_encode("$username:$password"),
'Content-Type: application/json'
),
));
$response = curl_exec($curl);
curl_close($curl);
$response = json_decode($response);
if ($response->succeeded == true)
return $response->data->credit;
return false;
}
function sending_default_asiatech($username, $password, $smsNumber, $phoneNumbers, $text)
{
$phoneNumbers = explode(",", $phoneNumbers);
foreach ($phoneNumbers as $phoneNumber) {
$phoneNumber = '98'.substr($phoneNumber, 1);
$postFields[] = [
"SourceAddress" => $smsNumber,
"MessageText" => $text,
"DestinationAddress" => $phoneNumber
];
}
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => SEND_URI,
CURLOPT_PROXY => PROXY,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => json_encode($postFields),
CURLOPT_HTTPHEADER => array(
'Authorization: Basic ' . base64_encode("$username:$password"),
'Content-Type: application/json'
),
));
$response = curl_exec($curl);
curl_close($curl);
$response = json_decode($response);
if ($response->succeeded == true)
return true;
return false;
}
function sending_pattern_asiatech()
{
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment