ai地址动态

This commit is contained in:
meimei
2025-04-21 17:24:32 +08:00
parent 5eec69b7ea
commit 702953a91e
5 changed files with 20 additions and 9 deletions

View File

@@ -37,7 +37,7 @@ class BaseWechatLogic
if(empty($this->base_url)){ if(empty($this->base_url)){
throw new \Exception('请先设置ai客服配置'); throw new \Exception('请先设置ai客服配置');
} }
$tokenArr = (new TokenWechatLogic())->getToken(); $tokenArr = (new TokenWechatLogic())->getToken($this->base_url);
$postdata['appId'] = $tokenArr['appId']; $postdata['appId'] = $tokenArr['appId'];
$domain = $this->base_url; $domain = $this->base_url;
$timeout = 4; $timeout = 4;

View File

@@ -26,10 +26,15 @@ class TokenWechatLogic
* authorwh * authorwh
* @throws \Exception * @throws \Exception
*/ */
function getToken() function getToken($url='')
{ {
$base_url = SundryConfig::val('py_app_base_url'); // $base_url = SundryConfig::val('py_app_base_url');
$url = $base_url.'/vip_groups/auth_info'; // $url = $base_url.'/vip_groups/auth_info';
if (empty($url)){
throw new \Exception('获取url失败');
}
$base_url = parse_url($url);
$url = $base_url['scheme'].'://'.$base_url['host'].'/vip_groups/auth_info';
$res = \wanghua\general_utility_tools_php\http\Curl::curl_post($url, []); $res = \wanghua\general_utility_tools_php\http\Curl::curl_post($url, []);
if(empty($res['data'])){ if(empty($res['data'])){
throw new \Exception('获取token失败'); throw new \Exception('获取token失败');

View File

@@ -133,7 +133,7 @@ class Tasktimer extends Controller
$logic = new MessageWechatLogic(); $logic = new MessageWechatLogic();
$logic->setBaseUrl($base_url); $logic->setBaseUrl($base_url);
$tokenArr = (new TokenWechatLogic())->getToken(); $tokenArr = (new TokenWechatLogic())->getToken($base_url);
$data = [ $data = [
'appId'=>$tokenArr['appId'], 'appId'=>$tokenArr['appId'],
'toWxid'=>$cust['rel_group'],//是群则发送群消息,否则发个人私人消息 'toWxid'=>$cust['rel_group'],//是群则发送群消息,否则发个人私人消息
@@ -203,7 +203,7 @@ class Tasktimer extends Controller
->where('id',$customer_record['aicustomerservice_ids']) ->where('id',$customer_record['aicustomerservice_ids'])
->find(); ->find();
$tokenArr = (new TokenWechatLogic())->getToken(); $tokenArr = (new TokenWechatLogic())->getToken($ai_config['server_url']);
if(empty($ai_config)){ if(empty($ai_config)){
return Tools::set_fail('有'.$msg.'计划无ai客服服务该客户'); return Tools::set_fail('有'.$msg.'计划无ai客服服务该客户');

View File

@@ -37,7 +37,7 @@ class BaseWechatLogic
if(empty($this->base_url)){ if(empty($this->base_url)){
throw new \Exception('请先设置ai客服配置'); throw new \Exception('请先设置ai客服配置');
} }
$tokenArr = (new TokenWechatLogic())->getToken(); $tokenArr = (new TokenWechatLogic())->getToken($this->base_url);
$postdata['appId'] = $tokenArr['appId']; $postdata['appId'] = $tokenArr['appId'];
$domain = $this->base_url; $domain = $this->base_url;
$timeout = 4; $timeout = 4;

View File

@@ -25,9 +25,15 @@ class TokenWechatLogic extends BaseWechatLogic
* @return string * @return string
* @throws \Exception * @throws \Exception
*/ */
function getToken() function getToken($url ='')
{ {
$url = 'https://wechat-api-test.excn.vip/vip_groups/auth_info'; if (empty($url)){
throw new \Exception('获取url失败');
}
// $url = 'https://wechat-api-test.excn.vip/vip_groups/auth_info';
$base_url = parse_url($url);
$url = $base_url['scheme'].'://'.$base_url['host'].'/vip_groups/auth_info';
$res = \wanghua\general_utility_tools_php\http\Curl::curl_post($url, []); $res = \wanghua\general_utility_tools_php\http\Curl::curl_post($url, []);
if(empty($res['data'])){ if(empty($res['data'])){
throw new \Exception('获取token失败'); throw new \Exception('获取token失败');