From 2ef3a54e7f42147d053cfb96aaf295773cfaf9d7 Mon Sep 17 00:00:00 2001 From: liapples Date: Sun, 14 Nov 2021 19:02:19 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E5=B0=8F=E7=A8=8B=E5=BA=8F=E7=94=A8=E6=88=B7=E9=9A=90=E7=A7=81?= =?UTF-8?q?=E4=BF=9D=E6=8A=A4=E6=8C=87=E5=BC=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Service/UploadMiniProgram.php | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/app/Service/UploadMiniProgram.php b/app/Service/UploadMiniProgram.php index c8c7c40..355272c 100644 --- a/app/Service/UploadMiniProgram.php +++ b/app/Service/UploadMiniProgram.php @@ -1,6 +1,7 @@ appid, 1); } + //配置小程序用户隐私保护指引:https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/privacy_config/set_privacy_setting.html + $redis_key = 'mini_program_set_privacy'; + if (!Redis::hget($redis_key, $agent->appid)) { + $data = [ + 'privacy_ver' => 2, //1表示现网版本;2表示开发版。默认是2开发版 + 'owner_setting' => [ + 'contact_phone' => AdminSetting::val('service_component_phone'), + 'notice_method' => '系统公告', + ], + 'setting_list' => [ + [ + "privacy_key" => "Location", + "privacy_desc" => "位置信息", + ], + [ + "privacy_key" => "PhoneNumber", + "privacy_desc" => "手机号", + ], + ], + ]; + + $res = $code->httpPostJson('cgi-bin/component/setprivacysetting', $data); + if (!isset($res['errcode'], $res['errmsg']) || $res['errcode'] != 0 || $res['errmsg'] != 'ok') { + throw new Exception('配置小程序用户隐私保护指引失败,原因:' . $res['errmsg'] ?? (is_array($res) ? join(',', $res) : '未知')); + } + Redis::hset($redis_key, $agent->appid, 1); + } + echo "上传成功,并已提交审核"; } else if (isset($audit_err_code[$res['errcode']])) { throw new Exception($audit_err_code[$res['errcode']]);