|
|
@ -78,23 +78,23 @@ class UploadMiniProgram |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
//设置域名,如果之前已经设置过了将记录下来,不再设置
|
|
|
//设置域名,如果之前已经设置过了将记录下来,不再设置
|
|
|
$host = env('APP_URL'); |
|
|
|
|
|
$redis_key = 'mini_program_set_host:' . substr(md5($host), 0, 10); |
|
|
|
|
|
|
|
|
$hosts = [env('APP_URL'), 'https://apis.map.qq.com']; |
|
|
|
|
|
$redis_key = 'mini_program_set_host:' . substr(md5(join($hosts)), 0, 10); |
|
|
if (!Redis::hget($redis_key, $agent->appid)) { |
|
|
if (!Redis::hget($redis_key, $agent->appid)) { |
|
|
/** @var \EasyWeChat\OpenPlatform\Authorizer\MiniProgram\Domain\Client $domain */ |
|
|
/** @var \EasyWeChat\OpenPlatform\Authorizer\MiniProgram\Domain\Client $domain */ |
|
|
$domain = $miniProgram['domain']; |
|
|
$domain = $miniProgram['domain']; |
|
|
|
|
|
|
|
|
$param = [ |
|
|
$param = [ |
|
|
"action" => "add", |
|
|
"action" => "add", |
|
|
"requestdomain" => [$host], |
|
|
|
|
|
"wsrequestdomain" => [str_replace('http', 'ws', $host)], |
|
|
|
|
|
"uploaddomain" => [$host], |
|
|
|
|
|
"downloaddomain" => [$host], |
|
|
|
|
|
|
|
|
"requestdomain" => $hosts, |
|
|
|
|
|
"wsrequestdomain" => [str_replace('http', 'ws', $hosts)], |
|
|
|
|
|
"uploaddomain" => $hosts, |
|
|
|
|
|
"downloaddomain" => $hosts, |
|
|
]; |
|
|
]; |
|
|
$domain->modify($param); //服务器域名,服务器域名多次设置仅第一次成功,这里不校验返回结果正确性
|
|
|
$domain->modify($param); //服务器域名,服务器域名多次设置仅第一次成功,这里不校验返回结果正确性
|
|
|
$res = $domain->setWebviewDomain([$host]); //业务域名
|
|
|
|
|
|
|
|
|
$res = $domain->setWebviewDomain($hosts); //业务域名
|
|
|
if (!isset($res['errcode'], $res['errmsg']) || $res['errcode'] != 0 || $res['errmsg'] != 'ok') { |
|
|
if (!isset($res['errcode'], $res['errmsg']) || $res['errcode'] != 0 || $res['errmsg'] != 'ok') { |
|
|
throw new Exception("设置业务域名{$host}失败,原因:" . $res['errmsg'] ?? (is_array($res) ? join(',', $res) : '未知')); |
|
|
|
|
|
|
|
|
throw new Exception('设置业务域名'.join(';', $hosts).'失败,原因:' . $res['errmsg'] ?? (is_array($res) ? join(',', $res) : '未知')); |
|
|
} |
|
|
} |
|
|
Redis::hset($redis_key, $agent->appid, 1); |
|
|
Redis::hset($redis_key, $agent->appid, 1); |
|
|
} |
|
|
} |
|
|
|