PHP code example of lifetime / service
1. Go to this page and download the library: Download lifetime/service 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/ */
lifetime / service example snippets
$order = \service\WeChat::official()->user()->getUserInfo();
return [
// 阿里云(支付宝)相关参数
'ali' => [
'accessKey_id' => '',
'accessKey_secret' => '',
// OSS相关配置
'oss_endpoint' => '',
'oss_bucketName' => '',
// 支付相关参数
'sandbox' => true, // 是否是沙箱环境
'appid' => '20210001166', // 支付宝APPID (测试数据)
'public_key' => '', // 应用公钥
'private_key' => '', // 应用私钥
'alipay_public_key' => '', // 支付宝公钥
],
// 微信相关参数
'wechat' => [
// 公众号
'official_appid' => '', // 公众号appid(测试数据)
'official_app_secret' => '', // 公众号sercet(测试数据)
// 小程序
'miniapp_appid' => '',
'miniapp_app_secret' => '',
'mch_id' => '', // 商户ID (测试数据)
'mch_key' => '', // 商户支付密钥 (测试数据)
'mch_key_v3' => '', // 商户支付密钥 v3(测试数据)
'ssl_cer' => '', // 证书cert.pem路径
'ssl_key' => '', // 证书key.pem路径
],
// 字节跳动相关参数
'byteDance' => [
'miniapp_appid' => '', // 字节小程序APPID
'miniapp_secret' => '', // 字节小程序APP Secret
'miniapp_pay_mch_id' => '', // 字节小程序支付商户号
'miniapp_pay_appid' => '', // 字节小程序支付APPPID
'miniapp_pay_secret' => '', // 字节小程序支付secret
],
// 类库运行相关参数
'cache_path' => '', // 缓存目录
'cache_callable' => [ // 自定义缓存操作方法(如果设置了此参数,缓存目录将不再生效)
'set' => null, // 写入缓存
'get' => null, // 获取缓存
'del' => null, // 删除缓存
'put' => null, // 写入文件
]
];
\service\Config::setKey('my-service');
>
$config = [
// 阿里云(支付宝)相关参数
'ali' => [
// OSS相关配置
'accessKey_id' => '',
'accessKey_secret' => '',
'oss_endpoint' => '',
'oss_bucketName' => '',
// 支付相关参数
'sandbox' => true, // 是否是沙箱环境
'appid' => '20210001166', // 支付宝APPID (测试数据)
'public_key' => '', // 应用公钥
'private_key' => '', // 应用私钥
'alipay_public_key' => '', // 支付宝公钥
]
];
\service\Config::init($config);
>