|
|
@ -19,10 +19,24 @@ class AutoReply{
|
|
|
|
$queryUrl = 'https://api.weixin.qq.com/cgi-bin/get_current_autoreply_info?access_token=' . AccessToken::getAccessToken();
|
|
|
|
$queryUrl = 'https://api.weixin.qq.com/cgi-bin/get_current_autoreply_info?access_token=' . AccessToken::getAccessToken();
|
|
|
|
// 定义请求方法为POST
|
|
|
|
// 定义请求方法为POST
|
|
|
|
$queryAction = 'POST';
|
|
|
|
$queryAction = 'POST';
|
|
|
|
$template = array();// 初始化模板数组
|
|
|
|
// 初始化模板数组
|
|
|
|
$template['industry_id1'] = "$industryId1"; // 设置主行业ID
|
|
|
|
$template = array();
|
|
|
|
$template['industry_id2'] = "$industryId2";// 设置副行业ID
|
|
|
|
// 设置主行业ID
|
|
|
|
$template = json_encode($template);// 将模板数组转换为JSON格式
|
|
|
|
$template['industry_id1'] = "$industryId1";
|
|
|
|
return Curl::callWebServer($queryUrl, $template, $queryAction);// 调用Curl类的方法发送请求并获取结果
|
|
|
|
// 设置副行业ID
|
|
|
|
|
|
|
|
$template['industry_id2'] = "$industryId2";
|
|
|
|
|
|
|
|
// 将模板数组转换为JSON格式
|
|
|
|
|
|
|
|
$template = json_encode($template);
|
|
|
|
|
|
|
|
// 调用Curl类的方法发送请求并获取结果
|
|
|
|
|
|
|
|
return Curl::callWebServer($queryUrl, $template, $queryAction);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
类声明:class AutoReply 定义了一个名为 AutoReply 的类,用于处理微信公众号的自动回复功能。
|
|
|
|
|
|
|
|
方法声明:public static function getRole($industryId1, $industryId2) 定义了一个静态方法 getRole,用于获取自动回复规则。该方法接受两个参数:主行业ID ($industryId1) 和副行业ID ($industryId2)。
|
|
|
|
|
|
|
|
构建请求URL:$queryUrl = 'https://api.weixin.qq.com/cgi-bin/get_current_autoreply_info?access_token=' . AccessToken::getAccessToken(); 构建请求微信API的URL,使用 AccessToken::getAccessToken() 方法获取 access_token 并拼接到URL中。
|
|
|
|
|
|
|
|
定义请求方法:$queryAction = 'POST'; 设置请求方法为POST。
|
|
|
|
|
|
|
|
初始化模板数组:$template = array(); 创建一个空数组用于存储请求数据。
|
|
|
|
|
|
|
|
设置主行业ID:$template['industry_id1'] = "$industryId1"; 将主行业ID添加到模板数组中。
|
|
|
|
|
|
|
|
设置副行业ID:$template['industry_id2'] = "$industryId2"; 将副行业ID添加到模板数组中。
|
|
|
|
|
|
|
|
转换为JSON格式:$template = json_encode($template); 将模板数组转换为JSON字符串,以便发送给微信API。
|
|
|
|
|
|
|
|
发送请求并获取结果:return Curl::callWebServer($queryUrl, $template, $queryAction); 使用 Curl::callWebServer 方法发送POST请求到微信API,并返回结果。
|