wang hou sheng 8 months ago
parent 631b01cea7
commit 6e0d4778d0
  1. 29
      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 [];
$result = json_decode($result, true);
if ($result && !empty($result['errmsg']) && $result['errmsg'] == 'ok') {
return true;
}
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);
}
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']);
}
}
}

Loading…
Cancel
Save