`) } } } }) } {/block}
```
--------------------------------
### Implement AgentConfig in JavaScript
Source: https://github.com/niuzhiyun/niucloud-admin-single/blob/master/niucloud/vendor/w7corp/easywechat/docs/src/5.x/wework/jssdk.md
Frontend example demonstrating the initialization of wx.config followed by wx.agentConfig.
```js
```
--------------------------------
### Start the development server
Source: https://github.com/niuzhiyun/niucloud-admin-single/blob/master/niucloud/vendor/topthink/framework/README.md
Navigate to the project directory and launch the built-in PHP development server.
```bash
cd tp
php think run
```
--------------------------------
### Get Card Instance
Source: https://github.com/niuzhiyun/niucloud-admin-single/blob/master/niucloud/vendor/w7corp/easywechat/docs/src/4.x/official-account/card.md
Retrieves the card API instance. No setup or imports are explicitly shown.
```php
$card = $app->card;
```
--------------------------------
### GET approvalRecords
Source: https://github.com/niuzhiyun/niucloud-admin-single/blob/master/niucloud/vendor/w7corp/easywechat/docs/src/4.x/wework/oa.md
Retrieves approval records within a specified time range, optionally starting from a specific approval number.
```APIDOC
## GET approvalRecords
### Description
Retrieves approval records for a given time range. Supports pagination via the nextNumber parameter.
### Parameters
#### Query Parameters
- **startTime** (int) - Required - Start timestamp of the query range.
- **endTime** (int) - Required - End timestamp of the query range.
- **nextNumber** (int) - Optional - The first approval number to fetch; if omitted, starts from the first record in the range.
### Request Example
$app->oa->approvalRecords(1492617600, 1492790400, '201704240001');
```
--------------------------------
### Manage Installation Wizard Navigation
Source: https://github.com/niuzhiyun/niucloud-admin-single/blob/master/niucloud/app/install/view/base.html
Handles step-by-step navigation and UI state updates using jQuery.
```javascript
var index=0; $(document).ready(function(){ $("#education").addClass('main-hide'); $("#work").addClass('main-hide'); $("#social").addClass('main-hide'); $('#previous_step').hide(); /*上一步*/ $('#previous_step').bind('click', function () { index--; ControlContent(index); }); /*下一步*/ $('#next_step').bind('click', function () { index++; ControlContent(index); }); }); function ControlContent(index) { var stepContents = ["basicInfo","education","work","build","social"]; var key;//数组中元素的索引值 for (key in stepContents) { var stepContent = stepContents[key];//获得元素的值 if (key == index) { if(stepContent=='basicInfo'){ $('#previous_step').hide(); }else{ $('#previous_step').show(); } if(stepContent=='social'){ $('#next_step').hide(); }else{ $('#next_step').show(); } $('#'+stepContent).removeClass('main-hide'); $('#point'+key).addClass('c-select'); $('#line'+key).removeClass('b-select'); }else { $('#'+stepContent).addClass('main-hide'); if(key>index){ $('#point'+key).removeClass('c-select'); $('#line'+key).removeClass('b-select'); }else if(key{ let tips = window.localStorage.getItem('pageToLinkTips') if(tips){ pageToLink(type) return false } layer.open({ type: 1, // page 层类型 area: ['400px', '230px'], title: '提示', shade: 0.6, // 遮罩透明度 shadeClose: true, // 点击遮罩区域,关闭弹层 anim: 0, // 0-6 的动画形式,-1 不开启 content: `
` }); } // 页面跳转 function pageToLink(type,flag = false){ if(flag){ window.localStorage.setItem('pageToLinkTips', true) } if(type == 'admin'){ layer.closeAll() window.open('{$root_url}/admin/') }else if(type == 'web'){ layer.closeAll() window.open('{$root_url}/web/') }else if(type == 'wap'){ layer.closeAll() window.open('{$root_url}/wap/') } } {/block}
```
--------------------------------
### GET /certificates
Source: https://github.com/niuzhiyun/niucloud-admin-single/blob/master/niucloud/vendor/w7corp/easywechat/docs/src/5.x/micro-merchant/certficates.md
Retrieves the WeChat platform certificate. Note: Ensure the PHP sodium extension is installed if not returning raw data.
```APIDOC
## GET /certificates
### Description
Retrieves the platform certificate from WeChat Pay. Before calling this, ensure the API certificate has been upgraded in the WeChat Pay merchant platform.
### Method
GET
### Parameters
#### Query Parameters
- **returnRaw** (boolean) - Optional - If true, returns the raw XML response object. Defaults to false.
### Request Example
$app->certficates->get(false);
### Response
#### Success Response (200)
- **certificate_info** (array) - Decrypted certificate information when returnRaw is false.
- **raw_data** (string) - Raw XML content when returnRaw is true.
```
--------------------------------
### GET /certificates
Source: https://github.com/niuzhiyun/niucloud-admin-single/blob/master/niucloud/vendor/w7corp/easywechat/docs/src/4.x/micro-merchant/certficates.md
Retrieves the WeChat Pay platform certificate. Note: Ensure the PHP sodium extension is installed if not requesting raw data.
```APIDOC
## GET /certificates
### Description
Retrieves the platform certificate from WeChat Pay. It is recommended to cache the certificate after retrieval.
### Method
GET
### Parameters
#### Query Parameters
- **returnRaw** (boolean) - Optional - If true, returns the raw XML response object. Defaults to false.
### Request Example
$app->certficates->get(false);
### Response
#### Success Response (200)
- **certificate_info** (array) - Decrypted certificate information when returnRaw is false.
- **raw_data** (string) - Raw XML response body when returnRaw is true.
```
--------------------------------
### Initialize and Render Templates
Source: https://github.com/niuzhiyun/niucloud-admin-single/blob/master/niucloud/vendor/topthink/think-template/README.md
Configure the template engine and render output using instance methods.
```php
'./template/',
'cache_path' => './runtime/',
'view_suffix' => 'html',
];
$template = new Template($config);
// 模板变量赋值
$template->assign(['name' => 'think']);
// 读取模板文件渲染输出
$template->fetch('index');
// 完整模板文件渲染
$template->fetch('./template/test.php');
// 渲染内容输出
$template->display($content);
```
--------------------------------
### Paginated Batch Get Page Data
Source: https://github.com/niuzhiyun/niucloud-admin-single/blob/master/niucloud/vendor/w7corp/easywechat/docs/src/4.x/official-account/shake-around.md
Retrieves a paginated list of page data. Specify the starting index and the number of pages to retrieve, up to a maximum of 50.
```php
$result = $shakearound->page->list(0,2);
```
--------------------------------
### Get Customer Chat Records
Source: https://github.com/niuzhiyun/niucloud-admin-single/blob/master/niucloud/vendor/w7corp/easywechat/docs/src/3.x/staff.md
Retrieve historical chat records between customers and service agents. Specify start and end times, along with pagination parameters.
```php
$staff->records($startTime, $endTime, $pageIndex, $pageSize);
// example: $records = $staff->records('2015-06-07', '2015-06-21', 1, 20);
```
--------------------------------
### Get Group Chat Statistics (by Day)
Source: https://github.com/niuzhiyun/niucloud-admin-single/blob/master/niucloud/vendor/w7corp/easywechat/docs/src/5.x/wework/external-contact.md
Fetch group chat statistics aggregated by natural day. Requires a start and end date, and a list of user IDs.
```php
$dayBeginTime = 1600272000;
$dayEndTime = 1600444800;
$userIds = ['userid1', 'userid2'];
$app->external_contact_statistics->groupChatStatisticGroupByDay(int $dayBeginTime, int $dayEndTime, array $userIds);
```
--------------------------------
### Get Approval Records
Source: https://github.com/niuzhiyun/niucloud-admin-single/blob/master/niucloud/vendor/w7corp/easywechat/docs/src/5.x/wework/oa.md
Fetch approval records within a specified time range. Optionally, specify the 'nextNumber' to retrieve records starting from a particular approval number.
```php
$app->oa->approvalRecords(1492617600, 1492790400);
// 指定第一个拉取的审批单号,不填从该时间段的第一个审批单拉取
$app->oa->approvalRecords(1492617600, 1492790400, '201704240001');
```
--------------------------------
### Install Alibaba Cloud Client for PHP
Source: https://github.com/niuzhiyun/niucloud-admin-single/blob/master/niucloud/vendor/alibabacloud/client/README-zh-CN.md
Use Composer to add the client as a dependency in your project.
```bash
composer require alibabacloud/client
```
--------------------------------
### Initialize and Configure EasyWeChat Application
Source: https://github.com/niuzhiyun/niucloud-admin-single/blob/master/niucloud/vendor/w7corp/easywechat/docs/src/3.x/configuration.md
Demonstrates how to instantiate the Application and dynamically update configuration values after initialization.
```php
use EasyWeChat\Foundation\Application;
$options = [
// ...
];
$app = new Application($options);
/**
* 如果想要在Application实例化完成之后, 修改某一个options的值,
* 比如服务商+子商户支付回调场景, 所有子商户订单支付信息都是通过同一个服务商的$option 配置进来的,
* 当oauth在微信端验证完成之后, 可以通过动态设置merchant_id来区分具体是哪个子商户
*/
$app['config']->set('oauth.callback','wechat/oauthcallback/'. $sub_merchant_id->id);
```
--------------------------------
### Get Check-in Schedus
Source: https://github.com/niuzhiyun/niucloud-admin-single/blob/master/niucloud/vendor/w7corp/easywechat/docs/src/5.x/wework/oa.md
Retrieve check-in schedule information for employees within a specified time range. Requires start and end times, and a list of user IDs.
```php
$app->oa->checkinSchedus(int $startTime, int $endTime, array $userids);
```
--------------------------------
### TP6/TP5.1 Cache Constructor Configuration
Source: https://github.com/niuzhiyun/niucloud-admin-single/blob/master/niucloud/vendor/fastknife/ajcaptcha/demo.md
Example of configuring the cache constructor for ThinkPHP 6 or 5.1. This shows how to get a cache instance using the framework's cache facade.
```php
'constructor' => [\think\Facade\Cache::class, 'instance']
```
--------------------------------
### Get Check-in Monthly Report Data
Source: https://github.com/niuzhiyun/niucloud-admin-single/blob/master/niucloud/vendor/w7corp/easywechat/docs/src/5.x/wework/oa.md
Retrieve monthly check-in report data for specified users within a date range. Requires start and end times, and a list of user IDs.
```php
$app->oa->checkinMonthData(int $startTime, int $endTime, array $userids);
```
--------------------------------
### Get Check-in Daily Report Data
Source: https://github.com/niuzhiyun/niucloud-admin-single/blob/master/niucloud/vendor/w7corp/easywechat/docs/src/5.x/wework/oa.md
Retrieve daily check-in report data for specified users within a date range. Requires start and end times, and a list of user IDs.
```php
$app->oa->checkinDayData(int $startTime, int $endTime, array $userids);
```
--------------------------------
### Initialize Layui and Render Installation Template
Source: https://github.com/niuzhiyun/niucloud-admin-single/blob/master/niucloud/app/install/view/base.html
Initializes Layui modules and defines template blocks for resources and main content.
```html
layui.use(['layer', 'upload', 'element'], function() {}); {block name="resources"}{/block}
```
```html
{if is_url($install_config['logo'])}  {else/}  {/if}
```
```html
{notempty name="$install_config['website_url']"}* [官方网站]({$install_config['website_url']})
{/notempty} {notempty name="$install_config['bbs_url']"}* [技术论坛]({$install_config['bbs_url']})
{/notempty}
```
```html
{block name='main'}{/block}
```
--------------------------------
### Install Composer (Unix)
Source: https://github.com/niuzhiyun/niucloud-admin-single/blob/master/niucloud/vendor/tencentcloud/sms/README.MD
Use this command to install Composer on Unix-based systems. Ensure you have curl installed.
```bash
curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer
```
--------------------------------
### Install COS-PHP-SDK-V5 with Composer
Source: https://github.com/niuzhiyun/niucloud-admin-single/blob/master/niucloud/vendor/qcloud/cos-sdk-v5/README.md
Use Composer to manage dependencies and install the COS-PHP-SDK-V5. Ensure Composer is installed globally or locally.
```bash
composer require qcloud/cos-sdk-v5
```
```bash
curl -sS https://getcomposer.org/installer | php
```
```json
{
"require": {
"qcloud/cos-sdk-v5": "2.*"
}
}
```
```bash
php composer.phar install
```
--------------------------------
### GET 请求示例
Source: https://github.com/niuzhiyun/niucloud-admin-single/blob/master/niucloud/vendor/w7corp/easywechat/docs/src/6.x/client.md
通过 GET 方法获取用户列表。
```php
$response = $api->get('/cgi-bin/user/list', [
'next_openid' => 'OPENID1',
]);
```
--------------------------------
### Complete PHP Configuration Example
Source: https://github.com/niuzhiyun/niucloud-admin-single/blob/master/niucloud/vendor/w7corp/easywechat/docs/src/6.x/official-account/config.md
This snippet shows a full configuration array for the application. It includes essential details like AppID, AppSecret, Token, and EncodingAESKey for secure mode. It also outlines OAuth scopes and callback URLs, along with HTTP client settings such as timeout and retry configurations. It is recommended to only configure what is needed, as defaults are often sufficient.
```php
[
/**
* 账号基本信息,请从微信公众平台/开放平台获取
*/
'app_id' => 'your-app-id', // AppID
'secret' => 'your-app-secret', // AppSecret
'token' => 'your-token', // Token
'aes_key' => '', // EncodingAESKey,兼容与安全模式下请一定要填写!!!
/**
* OAuth 配置
*
* scopes:公众平台(snsapi_userinfo / snsapi_base),开放平台:snsapi_login
* callback:OAuth授权完成后的回调页地址
*/
'oauth' => [
'scopes' => ['snsapi_userinfo'],
'callback' => '/examples/oauth_callback.php',
],
/**
* 接口请求相关配置,超时时间等,具体可用参数请参考:
* https://github.com/symfony/symfony/blob/5.3/src/Symfony/Contracts/HttpClient/HttpClientInterface.php
*/
'http' => [
'timeout' => 5.0,
// 'base_uri' => 'https://api.weixin.qq.com/', // 如果你在国外想要覆盖默认的 url 的时候才使用,根据不同的模块配置不同的 uri
'retry' => true, // 使用默认重试配置
// 'retry' => [
// // 仅以下状态码重试
// 'http_codes' => [429, 500]
// // 最大重试次数
// 'max_retries' => 3,
// // 请求间隔 (毫秒)
// 'delay' => 1000,
// // 如果设置,每次重试的等待时间都会增加这个系数
// // (例如. 首次:1000ms; 第二次: 3 * 1000ms; etc.)
// 'multiplier' => 3
// ],
],
]
```
--------------------------------
### Initialize OssClient
Source: https://github.com/niuzhiyun/niucloud-admin-single/blob/master/niucloud/vendor/aliyuncs/oss-sdk-php/README-CN.md
Create an instance of the OssClient to interact with the OSS service.
```php
"; ;
$accessKeySecret = "<您从OSS获得的AccessKeySecret>";
$endpoint = "<您选定的OSS数据中心访问域名,例如oss-cn-hangzhou.aliyuncs.com>";
try {
$ossClient = new OssClient($accessKeyId, $accessKeySecret, $endpoint);
} catch (OssException $e) {
print $e->getMessage();
}
```
--------------------------------
### Initialization
Source: https://github.com/niuzhiyun/niucloud-admin-single/blob/master/niucloud/vendor/w7corp/easywechat/docs/src/4.x/open-platform/index.md
Initialize the Open Platform instance with your third-party platform credentials.
```APIDOC
## Initialization
### Description
Initialize the Open Platform instance with your third-party platform credentials.
### Method
N/A (Instantiation)
### Endpoint
N/A
### Parameters
#### Request Body
- **app_id** (string) - Required - Your third-party platform App ID.
- **secret** (string) - Required - Your third-party platform Secret.
- **token** (string) - Required - Your third-party platform Token.
- **aes_key** (string) - Required - Your third-party platform AES Key.
### Request Example
```php
'开放平台第三方平台 APPID',
'secret' => '开放平台第三方平台 Secret',
'token' => '开放平台第三方平台 Token',
'aes_key' => '开放平台第三方平台 AES Key'
];
$openPlatform = Factory::openPlatform($config);
```
### Response
N/A (Object instantiation)
```
--------------------------------
### Install hyperf/pimple
Source: https://github.com/niuzhiyun/niucloud-admin-single/blob/master/niucloud/vendor/hyperf/pimple/README.md
Use Composer to install the hyperf/pimple package.
```bash
composer require "hyperf/pimple:1.1.*"
```
--------------------------------
### Initialize Alibaba Cloud Client
Source: https://github.com/niuzhiyun/niucloud-admin-single/blob/master/niucloud/vendor/alibabacloud/client/README-zh-CN.md
Configure the client with your AccessKey ID and Secret to set it as the default client.
```php
asDefaultClient();
```
--------------------------------
### Server Basic Usage
Source: https://github.com/niuzhiyun/niucloud-admin-single/blob/master/niucloud/vendor/w7corp/easywechat/docs/src/5.x/official-account/server.md
Demonstrates the basic setup for handling incoming messages using a callback function.
```APIDOC
## POST /api/server
### Description
Handles incoming user messages and events from WeChat.
### Method
POST
### Endpoint
/api/server
### Parameters
#### Request Body
- **message** (object) - The incoming message object from WeChat.
### Request Example
```json
{
"message": {
"FromUserName": "user_openid",
"MsgType": "text",
"Content": "Hello"
}
}
```
### Response
#### Success Response (200)
- **response** (string) - The response to send back to WeChat, or an empty string/"SUCCESS" if no reply is needed.
#### Response Example
```
"您好!欢迎使用 EasyWeChat"
```
### Code Example (PHP)
```php
// Basic usage
$app->server->push(function ($message) {
// Process the message
return "您好!欢迎使用 EasyWeChat";
});
// In Laravel:
$response = $app->server->serve();
return $response;
// In native PHP:
$response->send();
```
```
--------------------------------
### Instantiate Open Platform Client
Source: https://github.com/niuzhiyun/niucloud-admin-single/blob/master/niucloud/vendor/w7corp/easywechat/docs/src/4.x/open-platform/authorizer-delegate.md
Initialize the Open Platform factory to begin managing authorized accounts.
```APIDOC
## PHP Initialization
### Description
Initialize the Open Platform instance using the provided configuration.
### Code Example
```php
use EasyWeChat\Factory;
$config = [// ...];
$openPlatform = Factory::openPlatform($config);
```
```
--------------------------------
### Mini Program Initialization
Source: https://github.com/niuzhiyun/niucloud-admin-single/blob/master/niucloud/vendor/w7corp/easywechat/docs/src/3.x/mini_program.md
Instantiate the Mini Program application with the necessary options.
```APIDOC
## Mini Program Initialization
### Description
Instantiate the Mini Program application with the necessary options.
### Method
N/A (Instantiation)
### Endpoint
N/A
### Request Body
```json
{
"options": {
"mini_program": {
"app_id": "string",
"secret": "string",
"token": "string",
"aes_key": "string"
}
// ... other options
}
}
```
### Request Example
```php
[
'app_id' => 'component-app-id',
'secret' => 'component-app-secret',
'token' => 'component-token',
'aes_key' => 'component-aes-key'
],
// ...
];
$app = new Application($options);
$miniProgram = $app->mini_program;
```
### Response
N/A (Returns an instance of the Mini Program application)
```
--------------------------------
### Call Mini Program API with AuthorizerAccessToken Class
Source: https://github.com/niuzhiyun/niucloud-admin-single/blob/master/niucloud/vendor/w7corp/easywechat/docs/src/6.x/open-platform/index.md
Initialize a mini program instance using the AuthorizerAccessToken class. This method is not recommended.
```php
// 方式三:不推荐
// $token 为你存到数据库的授权码 authorizer_access_token
$authorizerAccessToken = new AuthorizerAccessToken($authorizerAppId, $token);
$miniApp = $app->getMiniApp($authorizerAccessToken);
```
```php
// 调用小程序接口
$response = $miniApp->getClient()->get('cgi-bin/users/list');
```
--------------------------------
### Modify User Remark Example
Source: https://github.com/niuzhiyun/niucloud-admin-single/blob/master/niucloud/vendor/w7corp/easywechat/docs/src/5.x/official-account/user.md
Example of setting a user's remark to '僵尸粉'.
```php
$app->user->remark($openId, "僵尸粉");
```
--------------------------------
### Install Artful via Composer
Source: https://github.com/niuzhiyun/niucloud-admin-single/blob/master/niucloud/vendor/yansongda/artful/README.md
Use this command to install the Artful package in your PHP project.
```shell
composer require yansongda/artful:~1.1.0 -vvv
```
--------------------------------
### Chained Image Generation Steps
Source: https://github.com/niuzhiyun/niucloud-admin-single/blob/master/niucloud/vendor/kkokk/poster/README.md
This example demonstrates using the Poster Facades with separate method calls for configuration, canvas creation, image composition, and retrieval. This approach offers more flexibility in controlling the generation process.
```php
$Poster = Poster::config($params);
$Poster->buildIm($w,$h,$rgba,$alpha); # 创建画布
$Poster->buildImage($src,$dst_x,$dst_y,$src_x,$src_y,$src_w,$src_h,$alpha,$type); # 合成图片
$result = $Poster->getPoster(); # 获取合成后图片文件地址
```
--------------------------------
### Install package via Composer
Source: https://github.com/niuzhiyun/niucloud-admin-single/blob/master/niucloud/vendor/w7corp/easywechat/docs/src/4.x/installation.md
Use this command to install the required WeChat package into your project.
```shell
$ composer require overtrue/wechat:~4.0 -vvv
```
--------------------------------
### Initialize Work Application Instance
Source: https://github.com/niuzhiyun/niucloud-admin-single/blob/master/niucloud/vendor/w7corp/easywechat/docs/src/4.x/wework/menu.md
Configure and instantiate the work application using your corp ID and application secret. Ensure the secret corresponds to the application you intend to manage menus for.
```php
$config = [
'corp_id' => 'xxxxxxxxxxxxxxxxx',
'secret' => 'xxxxxxxxxx', // 应用的 secret
//...
];
$app = Factory::work($config);
```
--------------------------------
### Initialize Different EasyWeChat Applications
Source: https://github.com/niuzhiyun/niucloud-admin-single/blob/master/niucloud/vendor/w7corp/easywechat/docs/src/4.x/official-account/tutorial.md
Demonstrates how to initialize various application types within the EasyWeChat SDK using the Factory class.
```php
// 公众号
$app = Factory::officialAccount($config);
// 小程序
$app = Factory::miniProgram($config);
// 开放平台
$app = Factory::openPlatform($config);
// 企业微信
$app = Factory::work($config);
// 企业微信开放平台
$app = Factory::openWork($config);
// 微信支付
$app = Factory::payment($config);
```