This library prepares the data and send it to an API for sending emails, sms and other for Code Igniter and Laravel
Use the composer to install this library
composer require epicsweb/php-ci-messages
Create or edit a file in your code igniter application folder and set this vars: /application/config/epicsweb.php
<?php if( !defined('BASEPATH')) exit('No direct script access allowed');
$config['pm_url'] = 'YOUR_BASE_URL_API';
$config['pm_user'] = 'YOUR_PWD_USERS';
$config['pm_pass'] = 'YOUR_PWD_PASSWORD';
Set in your .env file
PM_URL=YOUR_BASE_URL_API;
PM_USER=YOUR_PWD_USERS;
PM_PASS=YOUR_PWD_PASSWORD;
Change file /application/config/config.php:
$config['composer_autoload'] = FALSE;
↓
$config['composer_autoload'] = realpath(APPPATH . '../vendor/autoload.php');
Call the "send_mail" function of this library with an array like unique param
$data = [
'app' => [
'enviado_por' => (string) 'aplicativo',
'app_id' => (int) 1,
'envio_id' => (int) 1,
'para_id' => (int) 1 //CLIENT_ID
],
'header' => [
'para' => (string) 'for@email.com',
'de_nome' => (string) 'YOUR NAME',
'de' => (string) 'from@yourname.com',
'reply_to' => (string) 'no-reply@yourname.com',
'copia' => (boolean) 0 //0 OR 1
],
'corpo' => [
'assunto' => (string) 'Email Subject',
'html' => (string) 'Email <br/> Content',
'texto' => (string) 'Email Content'
],
'tipo' => [
'email'
]
];
$message = new PhpMessages( 'ci' ); // 'ci' or 'laravel' framework params (default = ci)
$message = $message->send_mail( $data )
Call the "send_sms" function of this library with an array like unique param to send a new sms
$sms = [
'app' => [
'enviado_por' => (string) 'aplicativo',
'app_id' => (int) 1,
'envio_id' => (int) 1,
'para_id' => (int) 1 //CLIENT_ID
],
'header' => [
'para' => '5517911112222'
'de_nome' => 'EPICS',
'de' => 'epics@epics.com.br',
],
'corpo' => [
'assunto' => (string) 'Message Here',
'html' => (string) 'Message Here',
'texto' => (string) 'Message Here',
],
'tipo' => [
'sms'
]
];
$message = new PhpMessages( 'ci' ); // 'ci' or 'laravel' framework params (default = ci)
$message = $message->send_sms( $sms );
$data = [
'user_id' => 1,
'title' => 'New push notification',
'body' => 'Description of your push notification',
'customData' => []
];
$this->message->push_create($data);
$data = [
'user_id' => 1
];
$this->message->push_tokens($data);
$data = [
'user_id' => 1,
'token' => 'a1b2c3d4f5',
'device' => 'IOS|ANDROID|WEB'
];
$this->message->push_token_create($data);
$data = [
'token' => 'a1b2c3d4f5'
];
$this->message->push_remove($data);
Call the "mailchimp_edit" function of this library with an array like unique param to edit a member in Mailchimp list. Obs: if the member doesn't exist, the function will call mailchimp_create automatically.
$data = [
'id' = (string) 'abc123', // id da lista
'email_address' = 'user email',
'email_type' = 'email type',
'status' = 'member status',
'merge_fields' => [
'name' => (string) 'User name',
'country' => (string) 'User country',
'state' => (string) 'User state',
'city' => (string) 'User city',
'phone' => (string) 'User phone',
]
];
$message = new PhpMessages( 'ci' ); // 'ci' or 'laravel' framework params (default = ci)
$message = $message->mailchimp_edit( $data );
Call the "mailchimp_tag" function of this library with an array like unique param to edit tags from member in Mailchimp list.
$data = [
'id' = 'list id',
'email_address' = 'user email',
'tags' => [
'name' => (string) 'Tag Name',
'status' => (string) 'Tag Status' //active/inactive
]
];
$message = new PhpMessages( 'ci' ); // 'ci' or 'laravel' framework params (default = ci)
$message = $message->mailchimp_edit( $data );
Call the "notifications_create_or_update" function to create or update user configuration about many notifications.
$data = [
'users_id' => 1,
'contract_id' => 1,
'custom' => NULL,
'items' => [
[
'name' => 'store_new',
'email' => 0,
'pusher' => 1,
'smsm' => 0
],[
'name' => 'store_stock',
'email' => 0,
'pusher' => 1,
'smsm' => 0
]
]
];
$message = new PhpMessages( 'ci' ); // 'ci' or 'laravel' framework params (default = ci)
$message = $message->notifications_create_or_update( $data );
Use "notifications_get_all" function to get configurations about all notifications.
$data = [
'users_id' => 1,
'system' => 'store',
'custom' => NULL
];
$message = new PhpMessages( 'ci' ); // 'ci' or 'laravel' framework params (default = ci)
$message = $message->notifications_get_all( $data );
Use "notifications_get_one" function to get configurations about one notifications.
$data = [
'users_id' => 1,
'system' => 'store',
'custom' => NULL
];
$message = new PhpMessages( 'ci' ); // 'ci' or 'laravel' framework params (default = ci)
$message = $message->notifications_get_one( $data );
This project is licensed under the MIT License - see the LICENSE.md file for details