Dear developer,

Joomla! is not only the best CMS because of its core team; Joomla! is empowered by all the third-party extensions, professional or not, which add so many functionalities to any website.
Based on this success, we decided to open AcySMS to any addition using a the powerful Joomla Plugin system.

Create a SMS tag

ACYSMS uses the Joomla Plugin system to handle its tag system.

So the first thing you have to do is to create a standard Joomla plugin with the group "acysms" and install it on Joomla.

You can then modify the installed file plugins/acysms/example.php and plugins/acysms/example.xml to meet your needs. 

Functions are called if they exist, you don't have to define them all.

onACYSMSReplaceTags(&$message, $send = true)

This function enables you to replace your global tags.

What we call global tags is a tag which does not depend on the user information.
So this tag is the same for all users.

AcySMS will trigger this function during the preview and only one time during the send process.

There are two parameters for this function:

  • $message which is the message body
  • $send indicates if the message will be sent (set to true) or displayed on the browser (set to false)
You don't have to return anything, simply directly modify the Newsletter the way you want.
Show/Hide php code
View source
function onACYSMSReplaceTags(&$message, $send = true){
$message = 'I just set this text as message body';
if(!$send){
$message .= 'This message is displayed on the browser';
}
}
 

 

 

onACYSMSReplaceUserTags(&$message,&$user,$send = true)

This function enables you to replace your personal tags.

AcySMS will trigger this function each time an SMS is sent or displayed (on the archive version for example) for each user.

The last parameter $send enables you to know if the message will be sent (set to true) or displayed on the browser (set to false)

Show/Hide php code

View source
function onACYSMSReplaceUserTags(&$message,&$user,$send = true){
 
$message .= '<br/>this message is for '.$user->user_firstname;
if($send){
$message .= ' this message is sent';
}
}
 

API


Send a SMS to one user

Here is the documentation to send SMS directly to a user. This SMS won't be added into the queue and won't be visible in the AcySMS statistics.

Show/Hide php code

View source
 
 
if(!include_once(rtrim(JPATH_ADMINISTRATOR,DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.'components'.DIRECTORY_SEPARATOR.'com_acysms'.DIRECTORY_SEPARATOR.'helpers'.DIRECTORY_SEPARATOR.'helper.php')){
 
echo 'This code can not work without the AcySMS Component';
 return false;
 }
 
$messageClass = ACYSMS::get('class.message');
$senderProfileClass = ACYSMS::get('class.senderprofile');
 
 
 
//You should replace $message_id by the ID of the message you want to send and which have been created in AcySMS
 
$message_id = 10;
 
$message = $messageClass->get($message_id);
 
if(empty($message->message_senderprofile_id)){
 
    echo 'No sender profile found with this ID';
    return ;
}
 
$gateway = $senderProfileClass->getGateway($message->message_senderprofile_id);
if(!$gateway->open()){
    return;
}
 
$phoneHelper = ACYSMS::get('helper.phone');
 
 
 
//Here you should replace $receiver_phone by the phone number you want to send the SMS to
$phone = $phoneHelper->getValidNum($receiver_phone);
if(!$phone){
 
    echo 'Invalid phone number';
    return;
}
 
$status = $gateway->send($message->message_body,$phone);
$gateway->close();

 

Subscribe a user to your AcySMS groups

Here is the documentation to subscribe a user to your AcySMS groups..

Show/Hide php code

View source
 
 
if(!include_once(rtrim(JPATH_ADMINISTRATOR,DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.'components'.DIRECTORY_SEPARATOR.'com_acysms'.DIRECTORY_SEPARATOR.'helpers'.DIRECTORY_SEPARATOR.'helper.php')){
 
 echo 'This code can not work without the AcySMS Component';
 return false;
 }
$myUser = new stdClass();
$myUser->user_firstname = strip_tags($postData['firstname_field']); //Please replace firstname_field by your own field name (the name of the field "firstname").
$myUser->user_lastname = strip_tags($postData['lastname_field']); //Please replace lastname_field by your own field name (the name of the field "lastname").
$myUser->user_phone_number = strip_tags($postData['phone_number_field']); //Please replace phone_number_field by your own field name (the name of the field "phone_number").
$myUser->user_birthdate = strip_tags($postData['birthdate_field']); //Please replace birthdate_field by your own field name (the name of the field "birthdate").
$myUser->user_email = strip_tags($postData['email_field']); //Please replace email_field by your own field name (the name of the field "email").
 
$phoneHelper = ACYSMS::get('helper.phone');
$validPhone = $phoneHelper->getValidNum($myUser->user_phone_number);
if(!$validPhone){
    echo 'Invalid Phone Number';
    return false;
}
 
$userClass = ACYSMS::get('class.user');
$userId = $userClass->save($myUser);
 
$subscribe = array(3, 4, 5); //Specify here the ID of your groups separated by a comma, in this example the user will be subscribed to groups IDs 3,4 and 5.
 
$newSubscription = array();
if(!empty($subscribe)){
 foreach($subscribe as $groupId){
    $newList = array();
      $newList['status'] = 1;
     $newSubscription[$groupId] = $newList;
 }
}
$userClass->saveSubscription($userId, $newSubscription);
 
 

Follow us :