Code Monkey home page Code Monkey logo

api-php's Introduction

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".

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.

Index


Afilnet

Afilnet Cloud Marketing Logo

Afilnet is a company dedicated to Cloud Marketing.

With this module we seek to facilitate the use of the services we offer through our API.

We offer support to our clients if they have some trouble with their accounts or our services.

If you notice some error or bugs, feel free to contact us.

Website

We are available in 3 different languages:

back to top


Setup

ATTENTION: You need an Afilnet account with credits to use this module

If you dont have an account, visit our web page and create it.

After that, you will have to buy some credits to be able to send the notifications

We have a promo to test the services which give you 10 credits for free

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

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:

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

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

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

back to top


Afilnet API Services

There are 3 channels availables:

This library use the structure:

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

SMS

If you want to use SMS you only need to call the object sms and the service required.

Services

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

Example

<?php
$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 :(");
}
?>

back to top


Email

If you want to use Email you only need to call the object sms and the service required.

Services

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

Example

<?php
$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 :(");
}
?>

back to top


Voice

If you want to use Voice you only need to call the object sms and the service required.

Services

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

Example

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

back to top


RESPONSE

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

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

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:

  • 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


api-php's People

Contributors

afilnet avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Forkers

linkses

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.