2017 © Pedro PelĂĄez
 

library afilnet-api

PHP Library to use Afilet API

image

afilnet/afilnet-api

PHP Library to use Afilet API

  • Tuesday, June 14, 2016
  • by Afilnet
  • Repository
  • 1 Watchers
  • 0 Stars
  • 12 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

SMS, Email and Voice notifications

Easy to use

This library is designed to be an easy way to use Afilnet API services. You can send SMS, email and voice notifications using your Afilnet account. This package can be installed with composer using "composer require afilnet/afilnet-api"., (*1)

You only need an Afilnet account with enought credits. If you do not have an account, you can create an account in our website in a few minutes., (*2)

Index


Afilnet

Afilnet Cloud Marketing Logo, (*3)

Afilnet is a company dedicated to Cloud Marketing., (*4)

With this module we seek to facilitate the use of the services we offer through our API., (*5)

We offer support to our clients if they have some trouble with their accounts or our services., (*6)

If you notice some error or bugs, feel free to contact us., (*7)

Website

We are available in 3 different languages: - Español - www.afilnet.com - English - www.afilnet.com/en/ - Français - www.afilnet.com/fr/, (*8)

back to top, (*9)


Setup

ATTENTION: You need an Afilnet account with credits to use this module, (*10)

If you dont have an account, visit our web page and create it., (*11)

After that, you will have to buy some credits to be able to send the notifications, (*12)

We have a promo to test the services which give you 10 credits for free, (*13)

Once you have an account, we are ready to setup the module in your app:, (*14)

The first step is install the module, you can install it using composer or manual installation Composer: "composer require afilnet/afilnet-api". Then create the object:, (*15)

<?php
$afilnet = new \Afilnet\Afilnet();
?>

Then login with your account (If you dont login successfully, all services will return error bad username or password)., (*16)

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

And now we are ready to use the services :), (*17)

back to top, (*18)


Afilnet API Services

There are 3 channels availables: - Send SMS - Send Email - Send Voice, (*19)

This library use the structure:, (*20)

<?php
$afilnet->channel->service($params);
?>

The three channels have the same services: - send (Send to a single user) - sendFromTemplate (Send to a single user using a template) - sendToGroup (Send to a defined group) - sendToGroupFromTemplate (Send to a defined group using a template) - getDeliveryStatus (Get delivery status of a message), (*21)


SMS

If you want to use SMS you only need to call the object sms and the service required., (*22)

Services

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');
?>

Example

sms->send(
    to,
    message,
    from
);

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

back to top, (*23)


Email

If you want to use Email you only need to call the object sms and the service required., (*24)

Services

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');
?>

Example

I am your father.

Hehehe surprise., (*25)

Best wishes, Darth Vader., (*26)

"; $result = $afilnet->email->send( subject, to, message ); if (result['status']=="SUCCESS"){ echo("Nooooo!!!!!11"); } else { // == "ERROR" echo("I have not received any email :("); } ?>

back to top, (*27)


Voice

If you want to use Voice you only need to call the object sms and the service required., (*28)

Services

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');
?>

Example

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
);
?>

back to top, (*29)


RESPONSE

All services receive similar parameters but all return same array (json decoded)., (*30)

The services will return an array with the next structure: * status * error (if status=ERROR), here you will receive the error code * result (if status=SUCCESS), here you will receive the following values: * messageid * credits, (*31)

ERROR CODES

Code Description
MISSING_USER User or email not included
MISSING_PASSWORD Password not included
MISSING_CLASS Class not included
MISSING_METHOD Method not included
MISSING_COMPULSORY_PARAM Compulsory parameter not included
INCORRECT_USER_PASSWORD Incorrect user or password
INCORRECT_CLASS Incorrect class
INCORRECT_METHOD Incorrect method
NO_ROUTE_AVAILABLE There are no available paths for the indicated destination
NO_CREDITS Your balance is insufficient

Example

*Example for $afilnet->sms->send:, (*32)

  • If everything is ok:
<?php
$result = [
    "status" => "SUCCESS",
    "result" => [
        "messageid" => "id_from_message",
        "credits" => "credits_spent"
    ]    
]
?>
  • If something went bad:
<?php
$result = [
    "status" => "ERROR",
    "error" => "error_message"  
]
?>

back to top, (*33)


The Versions

14/06 2016

dev-master

9999999-dev

PHP Library to use Afilet API

  Sources   Download

MIT

The Requires

  • php >=5.3.3

 

api service email marketing php cloud sms message notification hosting voice afilnet

09/06 2016

v1.0.0

1.0.0.0

PHP Library to use Afilet API

  Sources   Download

MIT

The Requires

  • php >=5.3.3

 

api service email marketing php cloud sms message notification hosting voice afilnet