afilnet/afilnet-api 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

afilnet/afilnet-api

Composer 安装命令:

composer require afilnet/afilnet-api

包简介

PHP Library to use Afilet API

README 文档

README

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 = "luke_skywalker@newjediorder.com";
$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

afilnet/afilnet-api 适用场景与选型建议

afilnet/afilnet-api 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 8 次下载、GitHub Stars 达 3, 最近一次更新时间为 2022 年 06 月 21 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「php」 「api」 「email」 「sms」 「message」 「service」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 afilnet/afilnet-api 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 afilnet/afilnet-api 我们能提供哪些服务?
定制开发 / 二次开发

基于 afilnet/afilnet-api 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 8
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 15
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-06-21