Code Monkey home page Code Monkey logo

mife's Introduction

Dialog MIFE Package

MIFE API Handler is a plugin to handle REST API request for Dialog External and Internal MIFE APIs

  • Dialog SMS Gateway
  • Dialog Charging Gateway

Requirements

  • PHP 5.6 +
  • Phalcon / CI / CakePhp / Laravel 5.5+

Installation

=> Install the package by running this command in your terminal/cmd:

composer require nu1ww/mife

=> You need to setup below values in .env file

MIFE_BASE_URL=https://extmife.dialog.lk/extapi/xxxxx
MIFE_GRANT_TYPE=client_credentials
MIFE_BASE_64_AUTH=xxxxVHVFd2NGNm9Qc2ZCemR2UUhBYTpmR3VqT3BN*********************
MIFE_APP_ID=xxx
MIFE_APP_PASSWORD=xxxxx
MIFE_LOG=true // You can disable the logs using true and false
MIFE_ACCESS_TOKEN_STORE=DB // You can select the either "DB" or "FILE" to store the access_token

=> If you need keep record API request response logs in database set the below values in database and run MySql queries.

DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=test
DB_USERNAME=root
DB_PASSWORD=

=> Please run below mysql queries

CREATE TABLE `mife_log`  (
`id` int(0) NOT NULL AUTO_INCREMENT,
`request_url` text,
`request_method` text,
`request_header` text,
`request_body` text,
`http_status` text,
`response_header` text,
`response_body` text,
`date_time` datetime(0) DEFAULT now(),
PRIMARY KEY (`id`)
);

#---------------------------------------

CREATE TABLE `mife_access_token`  (
`id` int(0) NOT NULL AUTO_INCREMENT,
`json` text,
`date_time` datetime(0) DEFAULT now(),
PRIMARY KEY (`id`)
);

=> Send a SMS

$sendSms = new  \Mife\DialogSms\DialogSms();
$data = $sendSms->sendSms('779233884', 'This is test');

=> To get session key

$bill = new  \Mife\DialogAddToBill\DialogAddToBill();
$data = $bill->getSessionKey(); 

=> To check the credit balance

$bill = new  \Mife\DialogAddToBill\DialogAddToBill();
$data = $bill->creditCheck(779233884); 

=> Add to bill

$mobileNumber='777313687';
$invoiceNumber=3522;
$reasonCode=2071;
$amount=1;
$bill = new  \Mife\DialogAddToBill\DialogAddToBill();
$data = $bill->chargeToBill($mobileNumber, $invoiceNumber,$reasonCode, $amount); 

It has following functions:

  • Generate access token
MIFE::generateAccessToken();
  • Get access token
MIFE::getAccessToken();
  • Make the custom request
$accessToken = MIFE::getAccessToken();
$url = "https://extmife.dialog.lk/extapi/xyz";
$method = "POST";
$headers = [
    "Content-Type" => "application/json",
    "Authorization" => "Bearer " . $accessToken,
    "Accept" => "application/json",
];
$requestBody = [
    "param1" => 1234,
    "param2" => "param1",
];

// Rest API request and response get to a variable                
$response = MIFE::apiCall($url, $method, $headers, $requestBody);

// Get response body
$response->getBody();

// Get status code
$response->getStatusCode();

// Get response headers
$response->getHeaders();

Author

License

This project is licensed under the MIT License - see the LICENSE file for details

Special Thanks to

mife's People

Contributors

layoutindex avatar nu1ww avatar

Stargazers

Kavindu Bimsara Fernando avatar

Watchers

 avatar

Forkers

bimsaragamage

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.