### Get User List 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 fetching the user list and the expected JSON response structure. ```php $users = $app->user->list(); ``` ```json { "total": 2, "count": 2, "data": { "openid": [ "OPENID1", "OPENID2" ] }, "next_openid": "NEXT_OPENID" } ``` -------------------------------- ### Installation Status Logic Source: https://github.com/niuzhiyun/niucloud-admin-single/blob/master/niucloud/app/install/view/index/step-5.html Conditional rendering for installation success or manual build requirements. ```html {if $is_build == 1} 恭喜您!已成功安装{$install_config.website_name}。 {/if} {if $is_build == 0} 安装过程已结束,您还需要手动编译,才能正常使用! 如何手动编译请参考如下链接 [{$install_config.build_manual}]({$install_config.build_manual}) {/if} ``` -------------------------------- ### Install via Composer Source: https://github.com/niuzhiyun/niucloud-admin-single/blob/master/niucloud/vendor/dh2y/think-qrcode/README.md Standard installation method using the composer command line tool. ```bash composer require dh2y/think-qrcode ``` -------------------------------- ### Install hyperf/translation and hyperf/config Source: https://github.com/niuzhiyun/niucloud-admin-single/blob/master/niucloud/vendor/hyperf/pimple/README.md Install the necessary components for translation and configuration using Composer. ```bash composer require "hyperf/translation:1.1.*" composer require "hyperf/config:1.1.*" ``` -------------------------------- ### JavaScript Installation Logic Source: https://github.com/niuzhiyun/niucloud-admin-single/blob/master/niucloud/app/install/view/index/step-3.html Handles form validation, database connectivity testing, and the multi-step installation process. ```javascript ControlContent(2); var is_existdb = 1;//数据库是否存在 var message = '数据库账号或密码不能为空'; var is_install = false; function inputBoxPointer(id){ return document.getElementById(id); } layui.use('form', function(){ var form = layui.form; form.verify({ empty: function(value, item){ //value:表单的值、item:表单的DOM对象 if(value == ''){ var msg = $(item).attr("placeholder"); return msg; } } }); form.on('submit(install)', function(data){ if(is_existdb == 2){ layer.confirm('数据库存在,系统将覆盖数据库!', { btn: ['继续','取消'] //按钮 }, function(){ layer.closeAll(); install(data.field); }, function(){ layer.closeAll(); return false; }); }else{ if(is_existdb <= 0){ error(message); return false; } install(data.field); } return false; }); }); //数据库连接测试 function testDb() { var dbhost = inputBoxPointer('dbhost').value; var dbuser = inputBoxPointer('dbuser').value; var dbpwd = inputBoxPointer('dbpwd').value; var dbport = inputBoxPointer('dbport').value; inputBoxPointer('dbpwdsta').innerHTML=''; $.ajax({ //post也可 url: '{$root_url}/install.php/index/testdb', data: { dbhost: dbhost, dbport : dbport, dbuser:dbuser, dbpwd:dbpwd}, type: "post", dataType: 'json', success: function(data){ inputBoxPointer('dbpwdsta').innerHTML = data.data.message; is_existdb = data.data.status; message = data.data.message; } }); } /** *验证数据库是否存在 */ function haveDB() { var dbhost = inputBoxPointer('dbhost').value; var dbname = inputBoxPointer('dbname').value; var dbuser = inputBoxPointer('dbuser').value; var dbpwd = inputBoxPointer('dbpwd').value; var dbport = inputBoxPointer('dbport').value; inputBoxPointer('havedbsta').innerHTML=''; $.ajax({ //post也可 url: '{$root_url}/install.php/index/testdb', data: { dbhost: dbhost, dbport : dbport, dbuser:dbuser, dbpwd:dbpwd,dbname:dbname}, type: "post", dataType: 'json', success: function(data){ inputBoxPointer('havedbsta').innerHTML = data.data.message; is_existdb = data.data.status; message = data.data.message; } }); } function getStatus() { $.ajax({ url: "{$root_url}/install.php/index/getInstallInfo", dataType: 'json', type: 'get', success : function(data) { if(data.code == 1) { $(data.data.log).each(function (i, e){ if($('.log-'+i).length == 0) { let html = `
${e[0]}${e[1] == 'success' ? "成功" : ""} ${e[2]}
`; $('.install-log').append(html); SetScroll(); } }) if(data.data.status == 0 || data.data.status == 1) { setTimeout(() => { getStatus(); }, 200) }else{ $('#install-log .btn-box').removeClass('layui-hide') } } } }) } function install(data){ if(is_install) return false; $('#install-form').addClass('layui-hide') $('#install-log').removeClass('layui-hide') // $('.install-log').html('
正在安装...
'); $('.install-title').removeClass('layui-hide') $('.install-title').html('
正在安装...
'); $('.pright>.btn-box').addClass('layui-hide') is_install = true; $.ajax({ url: "{$root_url}/install.php/index/install", data: data, dataType: 'json', type: 'post', success : function(res) { layer.close(index); if(res.code == 1){ $.ajax({ url: "{$root_url}/install.php/index/initData", data: data, dataType: 'json', type: 'post', success : function(data) { if(data.code == 1){ installAfterData(function(){ window.location.href = '{$root_url}/install.php/index/build'; }) } } }) }else{ error(res.msg); is_install = false; } }, }) setTimeout(() => { getStatus(); }, 500) } function back(){ $('#install-form').removeClass('layui-hide') $('#install-log').addClass('layui-hide') $('.install-title').addClass('layui-hide') $('.pright>.btn-box').removeClass('layui-hide') } window.onload = SetScroll; function SetScroll(){ var height=$(".install-log")[0].scrollHeight; $(".install-log").scrollTop(height); } // 安装成功后初始化数据 function installAfterData(callback){ $.ajax({ url: "{$root_url}/install.php/index/installAfterData", dataType: 'json', type: 'post', success : function(data) { if(data.code == 1){ if(callback) callback() } } }) } ``` -------------------------------- ### Complete Example: HTML to Image Source: https://github.com/niuzhiyun/niucloud-admin-single/blob/master/niucloud/vendor/kkokk/poster/README.md A comprehensive example demonstrating loading HTML, applying transformations like transparency and size, rendering it, and then obtaining the image blob and file path. ```php use Kkokk\Poster\Facades\Html; $htmlObj = Html::load($html)->transparent()->size(338, 426)->render(); // 流文件 $blob = $htmlObj->getImageBlob(); // 文件地址 $file = $htmlObj->getFilePath(); ``` -------------------------------- ### Install Aliyun OSS SDK via Composer Source: https://github.com/niuzhiyun/niucloud-admin-single/blob/master/niucloud/vendor/aliyuncs/oss-sdk-php/README-CN.md Commands to install the SDK using Composer or declare it in your project configuration. ```bash $ composer require aliyuncs/oss-sdk-php ``` ```json "require": { "aliyuncs/oss-sdk-php": "~2.0" } ``` -------------------------------- ### Poster Facade Usage Example Source: https://github.com/niuzhiyun/niucloud-admin-single/blob/master/niucloud/vendor/kkokk/poster/README.md Basic example demonstrating the import and potential usage of the PosterManager facade for poster-related operations. ```php use Kkokk\Poster\PosterManager; use Kkokk\Poster\Exception\Exception; ``` -------------------------------- ### 合成图片示例 Source: https://github.com/niuzhiyun/niucloud-admin-single/blob/master/niucloud/vendor/kkokk/poster/README.md This example shows how to use the Poster class to build a composite image. It includes setting up the poster dimensions, adding text, a QR code, and a complex background with custom drawing operations. Ensure the Poster class and its dependencies are correctly installed and configured. ```php try { $result = Poster::extension('gd') ->config([ 'path' => __DIR__ . '/../poster/test1.png', // 'font' => 'static/simkai.ttf', // 'dpi' => 72 ]) ->buildIm(638, 826, [255, 255, 255, 127], false) // ->buildImage('https://test.acyapi.51acy.com/wechat/poster/top_bg.png') // ->buildImage('static/top_bg.png') // ->buildImage('https://test.acyapi.51acy.com/wechat/poster/half_circle.png', 254, 321) // ->buildImage('https://portrait.gitee.com/uploads/avatars/user/721/2164500_langlanglang_1601019617.png', 253, 326, 0, 0, 131, 131, false, 'circle') // ->buildImage('https://test.acyapi.51acy.com/wechat/poster/fengexian.png', 0, 655) // ->buildImage('https://test.acyapi.51acy.com/wechat/qrcode/poster_241.jpg',37,692,0,0,122,122) ->buildText('明月几时有,把酒问青天', ['center'], 200, 20, [52, 52, 52, 2], 0, '', 1, 40) ->buildText('明月几时有,把酒问青天', ['center'], 300, 20, [52, 52, 52, 2], 0, '', 1, 40) ->buildText('苏轼', 'center', 477, 16, [51, 51, 51, 1]) ->buildText('明月几时有,把酒问青天。不知天上宫阙,今夕是何年。', 'center', 515, 14, [153, 153, 153, 1]) ->buildText('长按识别', 497, 720, 15, [153, 153, 153, 1]) ->buildText('查看TA的更多作品', 437, 757, 15, [153, 153, 153, 1]) ->buildQr('http://www.baidu.com', 37, 692, 0, 0, 122, 122) ->buildBg(400, 500, ['color' => [ [255, 0, 0], [255, 125, 0], [255, 255, 0], [0, 255, 0], [0, 255, 255], [0, 0, 255], [255, 0, 255] ], 'alpha' => 80, 'to' => 'top', 'radius' => '20 30 40 80'], true, 'center', 'center', 0, 0, function ($im) { // $im->buildImage('https://test.acyapi.51acy.com/wechat/poster/top_bg.png'); $im->buildLine(10, 100, 100, 200, [0, 0, 0, 1], '', 10); // $im->buildLine(10, 30, 100, 100, [0, 0, 0, 1], 'rectangle', 10); // $im->buildLine(120, 10, 220, 100, [0, 0, 0, 1], 'filled_rectangle', 10); $im->buildArc(200, 200, 50, 50, 0, 360, [0, 0, 0, 1], '', 1); $im->buildText('明月几时有,把酒问青天,不知天上宫阙,今夕是何年', 'center', ['custom', 'center', 0, 100, 0], 20, [0, 0, 0, 50], 0, '', 1, 0); // $im->buildText('明月几时有', ['custom', 'right', 200, 400], ['custom', 'bottom', 200, 500, -20], 20, [0, 0, 0, 50]); }) ->getPoster(); } catch (Exception $e){ echo $e->getMessage(); } ``` -------------------------------- ### Install Think-Captcha Source: https://github.com/niuzhiyun/niucloud-admin-single/blob/master/niucloud/vendor/topthink/think-captcha/README.md Use Composer to install the think-captcha library. ```bash composer require topthink/think-captcha ``` -------------------------------- ### Install Qiniu PHP SDK using Composer Source: https://github.com/niuzhiyun/niucloud-admin-single/blob/master/niucloud/vendor/qiniu/php-sdk/README.md Use this command to install the Qiniu PHP SDK via Composer. Ensure Composer is installed and configured in your project. ```bash $ composer require qiniu/php-sdk ``` -------------------------------- ### Install ThinkTemplate via Composer Source: https://github.com/niuzhiyun/niucloud-admin-single/blob/master/niucloud/vendor/topthink/think-template/README.md Use this command to install the package in your project. ```bash composer require topthink/think-template ``` -------------------------------- ### CSS Styles for Installation UI Source: https://github.com/niuzhiyun/niucloud-admin-single/blob/master/niucloud/app/install/view/index/step-5.html Defines the visual layout for installation progress steps and the popup link wrapper. ```css {extend name="base"/} {block name="resources"} .install-content-procedure .content-procedure-item:first-of-type{ background: url("INSTALL_IMG/complete_two.png") no-repeat center / contain; color: #fff; } .install-content-procedure .content-procedure-item:nth-child(2), .install-content-procedure .content-procedure-item:nth-child(3){ background: url("INSTALL_IMG/complete_four.png") no-repeat center / contain; color: #fff; } .install-content-procedure .content-procedure-item:nth-child(4){ background: url("INSTALL_IMG/complete_three.png") no-repeat center / contain; color: #fff; } .install-content-procedure{border: none;} .pop-link-wrap{ display: flex; flex-direction: column; align-items: center; justify-content: center; } .pop-link-wrap .link-text{ font-size: 14px; } .pop-link-wrap .link-text:nth-child(2){ margin-top: 10px; } .pop-link-wrap .link-text:nth-child(2) a{ color: var(--base-color); } .pop-link-wrap .link-btn{ margin-top: 40px; } .pop-link-wrap button{ width: 160px; height: 40px; background: var(--base-color); color: #fff !important; } {/block} ``` -------------------------------- ### Install via PSR-4 Autoloading Source: https://github.com/niuzhiyun/niucloud-admin-single/blob/master/niucloud/vendor/dh2y/think-qrcode/README.md Manual installation steps and configuration for PSR-4 autoloading. ```json a) 进入vendor/dh2y目录 (没有dh2y目录 mkdir dh2y) b) git clone c) 修改 git clone下来的项目名称为think-qrcode d) 添加下面配置 "autoload": { "psr-4": { "dh2y\\qrcode\\": "vendor/dh2y/think-qrcode/src" } }, e) php composer.phar update ``` -------------------------------- ### CSS Installation Procedure Styling Source: https://github.com/niuzhiyun/niucloud-admin-single/blob/master/niucloud/app/install/view/index/step-3.html Defines the background images and text colors for the installation procedure steps. ```css .install-content-procedure .content-procedure-item:first-of-type{ background: url("INSTALL_IMG/complete_two.png") no-repeat center / contain; color: #fff; } .install-content-procedure .content-procedure-item:nth-child(2){ background: url("INSTALL_IMG/complete_four.png") no-repeat center / contain; color: #fff; } .install-content-procedure .content-procedure-item:nth-child(3){ background: url("INSTALL_IMG/conduct.png") no-repeat center / contain; color: #fff; } ``` -------------------------------- ### Order API Examples Source: https://context7.com/niuzhiyun/niucloud-admin-single/llms.txt Examples for interacting with the order API, including fetching order statistics, closing orders, confirming receipt, and retrieving logistics information. ```json { "code": 1, "msg": "success", "data": { "order_id": 10001, "order_no": "SH202401150001", "order_money": "9898.00", "goods_money": "9998.00", "delivery_money": "0.00", "discount_money": "100.00", "status": 2, "status_name": "待发货", "pay_time": "2024-01-15 10:35:00", "delivery_type": "express", "taker_name": "张三", "taker_mobile": "13800138000", "taker_full_address": "北京市朝阳区xxx街道xxx号", "member_remark": "请尽快发货", "goods_list": [] } } ``` ```bash curl -X GET "https://your-domain.com/api/shop/order/num" \ -H "Authorization: Bearer your_token" ``` ```bash curl -X PUT "https://your-domain.com/api/shop/order/close/10001" \ -H "Authorization: Bearer your_token" ``` ```bash curl -X PUT "https://your-domain.com/api/shop/order/finish/10001" \ -H "Authorization: Bearer your_token" ``` ```bash curl -X GET "https://your-domain.com/api/shop/order/logistics" \ -H "Authorization: Bearer your_token" \ -G \ --data-urlencode "order_id=10001" ``` -------------------------------- ### Install think-multi-app Package Source: https://github.com/niuzhiyun/niucloud-admin-single/blob/master/niucloud/vendor/topthink/think-multi-app/README.md Use Composer to install the think-multi-app package for ThinkPHP6. ```bash composer require topthink/think-multi-app ``` -------------------------------- ### Install EasyWeChat Console Tool Source: https://github.com/niuzhiyun/niucloud-admin-single/blob/master/niucloud/vendor/w7corp/easywechat/docs/src/5.x/payment/transfer.md Install the EasyWeChat console tool using Composer to manage RSA keys for bank transfers. ```bash $composer require easywechat/console -vvv ``` -------------------------------- ### Install ThinkPHP 8.0 via Composer Source: https://github.com/niuzhiyun/niucloud-admin-single/blob/master/niucloud/README.md Use this command to create a new project directory with the framework installed. ```bash composer create-project topthink/think tp ``` -------------------------------- ### Install Think-Trace with Composer Source: https://github.com/niuzhiyun/niucloud-admin-single/blob/master/niucloud/vendor/topthink/think-trace/README.md Use Composer to install the think-trace package. This command adds the extension to your ThinkPHP project. ```bash composer require topthink/think-trace ``` -------------------------------- ### Install EasyWeChat SDK Source: https://github.com/niuzhiyun/niucloud-admin-single/blob/master/niucloud/vendor/w7corp/easywechat/README.md Use Composer to install the EasyWeChat SDK. Ensure you have Composer version 2.0 or higher and PHP version 8.0.2 or higher. ```bash composer require w7corp/easywechat ``` -------------------------------- ### Example JSSDK Configuration Output Source: https://github.com/niuzhiyun/niucloud-admin-single/blob/master/niucloud/vendor/w7corp/easywechat/docs/src/5.x/basic-services/jssdk.md An example of the output generated by the JSSDK configuration, showing the structure of the `wx.config` object with debug, appId, timestamp, nonceStr, signature, and jsApiList. ```js ``` -------------------------------- ### Handle Cloud Build Logs and Installation Source: https://github.com/niuzhiyun/niucloud-admin-single/blob/master/niucloud/app/install/view/index/step-4.html Processes build log updates and manages the cloud installation lifecycle, including error handling and retry logic. ```javascript { if (!cloudBuildLog.includes(item.action)) { $('.build-log').append(`
> 正在执行:${item.action}
`) cloudBuildLog.push(item.action) if (item.code == 0) { error = item.msg $('.build-log').append(`
> error${item.msg}
`) $('.build-log').append(`
> 编译失败请不要关闭当前页面,请访问官方网站联系客服解决处理问题
`) } } }) } if (error) { $('.build-progress').hide() return } setTimeout(() => { getCloudBuildLog() }, 2000) } }); } function cloudBuild() { $.ajax({ url: '{$root_url}/index.php/adminapi/niucloud/build/install', headers: REQUEST_HEADER, type: "post", dataType: 'json', success: function(res){ if (res.code) { getCloudBuildLog() } else { if (res.msg.indexOf('队列') != -1) { $('.build-log').append(`
> 一键云安装小程序队列任务过多,请耐心等待
`) setTimeout(function (){ cloudBuild() }, 10000) } else { $('.build-log').append(`
> error${res.msg}
`) $('.build-log').append(`
> 编译失败请不要关闭当前页面,请访问官方网站联系客服解决处理问题
`) } } } }) } {/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'])} ![]({$install_config['logo']}) {else/} ![](INSTALL_IMG/{$install_config['logo']}) {/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); ```