diff --git a/app/common/library/wxserver/Server.php b/app/common/library/wxserver/Server.php index c207f788..90fc88c9 100644 --- a/app/common/library/wxserver/Server.php +++ b/app/common/library/wxserver/Server.php @@ -487,11 +487,17 @@ class Server } } - public function getPrivacySetting($appid) + /** + * @notes:设置隐私 + * @param $appid + * @return bool + * @author: wanghousheng + */ + public function getPrivacySetting($appid): bool { $token = $this->authorizerAccessToken($appid); if ($token) { - $url = "https://api.weixin.qq.com/cgi-bin/component/getprivacysetting?access_token=$token"; + $url = "https://api.weixin.qq.com/cgi-bin/component/setprivacysetting?access_token=$token"; $setting_list = [ ['privacy_key' => 'PhoneNumber', 'privacy_text' => '用于用户一键登录'], ['privacy_key' => 'Location', 'privacy_text' => '用于用户选择自提点'], @@ -505,21 +511,12 @@ class Server $data['owner_setting']['contact_qq'] = '527264601'; $data['owner_setting']['notice_method'] = '公告'; $result = $this->curlPost($url, json_encode($data)); - return json_decode($result, true); - } - return []; - } - - public function setPrivacySetting($appid) - { - $token = $this->authorizerAccessToken($appid); - if ($token) { - $url = "https://api.weixin.qq.com/cgi-bin/component/setprivacysetting?access_token=$token"; - $data['privacy_ver'] = 1; - $result = $this->curlPost($url, json_encode($data)); - return json_decode($result, true); + $result = json_decode($result, true); + if ($result && !empty($result['errmsg']) && $result['errmsg'] == 'ok') { + return true; + } } - return []; + return false; } public function apiText($authorization_code, $touser) @@ -589,6 +586,8 @@ class Server $model->insertGetId($insert_data); //设置域名信息 $this->setDomain($insert_data['appid'], $domain); + //设置隐私 + $this->getPrivacySetting($insert_data['appid']); } } }