kevinElken 21a71dcae7 feat: EK-744: 会员注册成功后,增加发送短信功能. 9 months ago
..
src 21a71dcae7 feat: EK-744: 会员注册成功后,增加发送短信功能. 9 months ago
.gitignore fda7fa2b85 feat: EK-744: 会员注册成功后,增加发送短信功能. 10 months ago
composer.json fda7fa2b85 feat: EK-744: 会员注册成功后,增加发送短信功能. 10 months ago
readme.md fda7fa2b85 feat: EK-744: 会员注册成功后,增加发送短信功能. 10 months ago

readme.md

EKNotifier Integration PHP SDK

This package is created as an easy wrapper for EKNotifier Service. It can be used in Laravel project or any PHP projects utilizing composer.

Todo

  • SMS Integration
  • Email Integration
  • Push Notification Integration

Installation

Include the repository as a VCS repository and require the version as dev-master

"repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/ElkenGit/eknotifier-php"
        }
    ],
    "require": {
        ...
        "elkengit/eknotifier-php": "dev-master"
    }

Then run composer update.

Note : Extra step for laravel user's only!!

Run php artisan vendor:publish --provider="ElkenGit\EknotifierPHP\EknotifierPhpServiceProvider"
This will create a eknotifier.php file under your config directory, fill it up.

Usage

SMS

<?php

use ElkenGit\EknotifierPHP\EknotifierSms;

// Instantiate without Laravel
$sms = new EknotifierSms(EKNOTIFIER_URL, APPLICATION_CODE, APPLICATION_PASSWORD);

// Instantiate with Laravel -- Must have config/eknotifier.php config filled
$sms = new EknotifierSms;

$phoneNumber = '0123456789'; // String, REQUIRED
$text = 'TEST SMS TEXT'; // String, REQUIRED
$userId = 1; // Integer, OPTIONAL (will be set to 0 if it's not given)

// Send the sms.
$sms->sendSMS($phoneNumber, $text, $userId); // Returns boolean
````

EMAIL

php <?php

use ElkenGit\EknotifierPHP\EknotifierEmail;

// Instantiate without Laravel $email = new EknotifierEmail(EKNOTIFIER_URL, APPLICATION_CODE, APPLICATION_PASSWORD);

// Instantiate with Laravel -- Must have config/eknotifier.php config filled $email = new EknotifierEmail;

// An array of recipients $emailsRecipients = [

['email' => 'user@email.com', 'user_id' => 1],
['email' => 'guest@email.com', 'user_id' => null],

];

$subject = 'EMAIL SUBJECT'; // String, REQUIRED $text = 'TEST EMAIL TEXT'; // String, REQUIRED

// Send the email. $email->sendEmail($emailsRecipients, $subject, $text); // Returns boolean ````