PHP code example of afilnet / afilnet-api

1. Go to this page and download the library: Download afilnet/afilnet-api library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

afilnet / afilnet-api example snippets

 

$afilnet = new \Afilnet\Afilnet();
 

if ($afilnet->login("username","password")){
    //You have logged in successfully
} else {
    //Bad credentials, you must login to use the services
}
 

$afilnet->channel->service($params);
 

//SEND
$array = $afilnet->sms->send(
    'from',
    'to', 
    'msg',
    'scheduledatetime', // (optional) 
    'output' // (optional)
);

//SEND FROM TEMPLATE
$array = $afilnet->sms->sendFromTemplate(
    'to', 
    'idTemplate', 
    'params', // (optional) 
    'scheduledatetime', // (optional) 
    'output' // (optional) 
);

//SEND TO GROUP
$array = $afilnet->sms->sendToGroup(
   'from', 
   'countryCode', 
   'idGroup', 
   'msg', 
   'scheduledatetime', // (optional) 
   'output' // (optional) 
);

//SEND TO GROUP FROM TEMPLATE
$array = $afilnet->sms->sendToGroupFromTemplate(
    'countryCode', 
    'idGroup', 
    'idTemplate', 
    'scheduledatetime', // (optional) 
    'output' // (optional) 
);

// GET DELIVERY STATUS
$array = $afilnet->sms->getDeliveryStatus('idMessage');
 

$to = "34600000000";
$message = "Hey Luke, I want to tell you something... I am your father.";
$from = "Darth Vader";

$result = $afilnet->sms->send(
    to,
    message,
    from
);

if (result['status']=="SUCCESS"){
    echo("Nooooo!!!!!11");
} else { // == "ERROR"
    echo("I have not received any sms :(");
}
 

//SEND
$array = $afilnet->email->send(
    'subject',
    'to', 
    'msg',
    'scheduledatetime', // (optional) 
    'output' // (optional)
);

//SEND FROM TEMPLATE
$array = $afilnet->email->sendFromTemplate(
    'to', 
    'idTemplate', 
    'params', // (optional) 
    'scheduledatetime', // (optional) 
    'output' // (optional) 
);

//SEND TO GROUP
$array = $afilnet->email->sendToGroup(
   'subject', 
   'idGroup', 
   'msg', 
   'scheduledatetime', // (optional) 
   'output' // (optional) 
);

//SEND TO GROUP FROM TEMPLATE
$array = $afilnet->email->sendToGroupFromTemplate(
    'idGroup', 
    'idTemplate', 
    'scheduledatetime', // (optional) 
    'output' // (optional) 
);

// GET DELIVERY STATUS
$array = $afilnet->email->getDeliveryStatus('idMessage');
 

$subject = "I have a surprise for you - Darth Vader";
$to = "[email protected]";
$message = "<h2>I am your father.</h2><hr><p>Hehehe surprise.</p><p>Best wishes, Darth Vader.</p>";

$result = $afilnet->email->send(
    subject,
    to,
    message
);

if (result['status']=="SUCCESS"){
    echo("Nooooo!!!!!11");
} else { // == "ERROR"
    echo("I have not received any email :(");
}
 

//SEND
$array = $afilnet->voice->send(
    'to', 
    'msg',
    'lang', // (optional) 
    'scheduledatetime', // (optional) 
    'output' // (optional)
);

//SEND FROM TEMPLATE
$array = $afilnet->voice->sendFromTemplate(
    'to', 
    'idTemplate', 
    'params', // (optional) 
    'scheduledatetime', // (optional) 
    'output' // (optional) 
);

//SEND TO GROUP
$array = $afilnet->voice->sendToGroup(
   'countryCode', 
   'idGroup', 
   'msg', 
   'scheduledatetime', // (optional) 
   'output' // (optional) 
);

//SEND TO GROUP FROM TEMPLATE
$array = $afilnet->voice->sendToGroupFromTemplate(
    'countryCode', 
    'idGroup', 
    'idTemplate', 
    'scheduledatetime', // (optional) 
    'output' // (optional) 
);

// GET DELIVERY STATUS
$array = $afilnet->voice->getDeliveryStatus('idMessage');
 

$to = "346000000";
$message = "Hey Luke, I want to tell you something... I... am... your father.";
$lang = "EN";

$result = $afilnet->voice->send(
    to,
    message,
    lang
);

if (result['status']=="SUCCESS"){
    echo("Wait, what?!... Nooooo!");
} else { // == "ERROR"
    echo("I have not received any phone call");
}


afilnet.sendEmail(
    to,
    message,
    function(result){
        if (result.status=="SUCCESS"){
            echo("Wait, what?!... Nooooo!");
        } else { // == "ERROR"
            echo("I have not received any phone call");
        }
    },
    lang
);
 

$result = [
    "status" => "SUCCESS",
    "result" => [
        "messageid" => "id_from_message",
        "credits" => "credits_spent"
    ]    
]
 

$result = [
    "status" => "ERROR",
    "error" => "error_message"  
]