PHP code example of lmh / api-module
1. Go to this page and download the library: Download lmh/api-module library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
lmh / api-module example snippets
php
namespace Test;
use ApiResponse\ApiResponse;
use ApiResponse\Application;
$server->setParams();
$params = $server->getParams();
$app = Application::getInstance($params['app_id'])->info();
//查询 appid校验
if (!$app) {
//查询数据库
$appInfo = ['app_id' => '88888888888888888', 'app_secret' => 'dasfasfafa41545458'];
$app = Application::getInstance($params['app_id'])->set($appInfo);
}
if (!$app) {
$response = $server->response(['status' => false, 'code' => '401']);
} else {
$server->setAppSecret($app['app_secret']);
$server->groupNameSpace = __NAMESPACE__;
$response = $server->run();
}
die($response);
}
}
(new demo())->index();