nu1ww / mife
1.2
2020-04-10 10:00 UTC
Requires
- php: >=5.6
- guzzlehttp/psr7: 1.6.1
This package is auto-updated.
Last update: 2024-09-22 17:31:42 UTC
README
MIFE API 处理器是一个插件,用于处理 Dialog 外部和内部 MIFE API 的 REST API 请求
- Dialog SMS 网关
- Dialog 充值网关
需求
- PHP 5.6+
- Phalcon / CI / CakePhp / Laravel 5.5+
安装
=> 在您的终端/命令行中运行以下命令安装此包
composer require nu1ww/mife
=> 您需要在 .env 文件中设置以下值
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
=> 如果您需要在数据库中记录 API 请求响应日志,请在数据库中设置以下值并运行 MySQL 查询。
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=test
DB_USERNAME=root
DB_PASSWORD=
=> 请运行以下 MySQL 查询
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`)
);
=> 发送 SMS
$sendSms = new \Mife\DialogSms\DialogSms(); $data = $sendSms->sendSms('779233884', 'This is test');
=> 获取会话密钥
$bill = new \Mife\DialogAddToBill\DialogAddToBill(); $data = $bill->getSessionKey();
=> 检查信用余额
$bill = new \Mife\DialogAddToBill\DialogAddToBill(); $data = $bill->creditCheck(779233884);
=> 添加到账单
$mobileNumber='777313687'; $invoiceNumber=3522; $reasonCode=2071; $amount=1; $bill = new \Mife\DialogAddToBill\DialogAddToBill(); $data = $bill->chargeToBill($mobileNumber, $invoiceNumber,$reasonCode, $amount);
具有以下功能
- 生成访问令牌
MIFE::generateAccessToken();
- 获取访问令牌
MIFE::getAccessToken();
- 执行自定义请求
$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();
作者
许可证
本项目采用 MIT 许可证授权 - 有关详细信息,请参阅 LICENSE 文件
特别感谢
- LAYOUTindex 团队