notifea/notifea-php
Composer 安装命令:
composer require notifea/notifea-php
包简介
Pure PHP repository for Notifea services.
README 文档
README
Pure PHP repository for using Notifea services.
Notifea provides clients very user-friendly way of sending transactional emails and sms to their users.
Install
To install the SDK you need to be using Composer in your project. To install it please see the docs.
After you installed Composer install the SDK
composer require notifea/notifea-php
Minimum requirements
This package will require you to use:
- PHP 7.0 or higher
- guzzlehttp/guzzle 6.0 or higher
- ext-json
Usage
All email and sms endpoints are accessed via NotifeaClient. First start by configuring this client.
$client = new NotifeaClient( 'https://api.notifea.com/v1', 'Bearer {authorization}' );
Your authentication token can be generated in access-tokens section.
Usage - emails
To interact with email endpoints use EmailService. First start by instantiating.
$client = new NotifeaClient( 'https://api.notifea.com/v1', 'Bearer {authorization}' ); $emailService = new EmailService($client);
Send email
Sending an email can be as simple as using this few lines of code:
$email = new Email(); $email->setFrom('newadress@notifea.com', 'New Address') ->setRecipient('customer@business.com') ->setReplyTo('reply_to@notifea.com') ->setSubject('My first email') ->setHtmlBody('<p>This is my first email</p>') ->setCc('cc@notifea.com') ; $sentEmail = $emailService->sendEmail($email);
$sentEmail will contain updated Email object with all interesting information.
Get emails
To get emails, use this piece of code:
$emails = $emailService->getEmails();
$emails will be a new Collection containing all returned Email objects
Get single email
To get a single email entity, only email uuid is needed:
$email = $emailService->getEmail('8fc2c850-81c0-4424-823a-aa4727441864');
$email will be an Email object
Delete email
To delete a single email entity from notifea database, usage of this function is sufficient
$result = $emailService->deleteEmail('8fc2c850-81c0-4424-823a-aa4727441864');
$result will be an either true on successful deletion or NotifeaException will be
triggered on any failure (such as email not found)
Usage - sms
To interact with sms endpoints use SmsService. First start by instantiating.
$client = new NotifeaClient( 'https://api.notifea.com/v1', 'Bearer {authorization}' ); $smsService = new SmsService($client);
Send sms
Sending an sms can be as simple as using this few lines of code:
$sms = new Sms(); $sms ->setRecipient('+421902739429') ->setSmsSenderid('59634971-e57f-44af-b530-038e27e7064e') ->setContent('My awesome SMS message.') ; $sentSms = $smsService->sendSms($sms);
$sentSms will contain updated Sms object with all interesting information.
To find out what is your sms_sender_id go into your Management section of your sms senders.
Get sms
To get all sms, use this piece of code:
$smss = $smsService->getSmss();
$smss will be a new Collection containing all returned Sms objects
Get single sms
To get a single sms entity, only sms uuid is needed:
$sms = $smsService->getSms('8fc2c850-81c0-4424-823a-aa4727441864');
$sms will be an Sms object
Delete sms
To delete a single sms entity from notifea database, this function is sufficient
$result = $smsService->deleteSms('8fc2c850-81c0-4424-823a-aa4727441864');
$result will be an either true on successful deletion or NotifeaException will be
triggered on any failure (such as sms not found)
Usage - sms senders
Since May our customers may interact with sms senders by using SmsSenderService. This is especially handy if you need to have
different Sender Names shown in your SMS
First start by instantiating.
$client = new NotifeaClient( 'https://api.notifea.com/v1', 'Bearer {authorization}' ); $smsSenderService = new SmsSenderService($client);
Create sms sender
Creating an sms sender can be as simple as using this few lines of code:
$smsSender = new SmsSender(); $smsSender ->setSenderName('My Sender') ; $createdSmsSender = $smsSenderService->createSmsSender($smsSender);
$createdSmsSender will contain updated SmsSender object with all interesting information such as your sms_sender_id that you need for sending SMS.
Get sms senders
To get all sms senders, use this piece of code:
$smsSenders = $smsSenderService->getSmsSenders();
$smsSenders will be a new Collection containing all returned SmsSender objects
Get single sms sender
To get a single sms sender entity, only sms sender uuid is needed:
$smsSender = $smsSenderService->getSmsSender('8fc2c850-81c0-4424-823a-aa4727441864');
$smsSender will be an SmsSender object
Update sms sender
To update a single sms sender entity, you may use updateSmsSender() method and pass in an SmsSender object with the updated data
$smsSender = new SmsSender(); $smsSender ->setUuid('8fc2c850-81c0-4424-823a-aa4727441864') // required in order to know which sms sender do you wish to update ->setSenderName('My New Name') ->setLiveTime(25) ; $result = $smsSenderService->updateSmsSender($smsSender);
Delete sms sender
To delete a single sms sender entity from notifea database, this function is sufficient
$result = $smsSenderService->deleteSmsSender('8fc2c850-81c0-4424-823a-aa4727441864');
$result will be an either true on successful deletion or NotifeaException will be
triggered on any failure (such as sms sender not found)
Community
Contributing
Dependencies are managed through composer:
$ composer install
Tests can be run via phpunit:
$ vendor/bin/phpunit
notifea/notifea-php 适用场景与选型建议
notifea/notifea-php 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.06k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2020 年 05 月 15 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「sms」 「emails」 「email-sending」 「sms-sending」 「transactional-emails」 「transactional-sms」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 notifea/notifea-php 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 notifea/notifea-php 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 notifea/notifea-php 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A laravel package for blacklisting or whitelisting specific email providers or domains
Emails addon for Bear Framework
Sendernet transactional email php API client
SDK for payment gateway PlatbaMobilom.sk for PHP7.0
Extensible library for building notifications and sending them via different delivery channels.
Nette wrapper for PHP language for Notifea services.
统计信息
- 总下载量: 1.06k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 18
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-05-15