|
|
|
@ -25,13 +25,17 @@ class CustomService
|
|
|
|
|
*/
|
|
|
|
|
public function addAccount($kfAccount, $nickname, $password)
|
|
|
|
|
{
|
|
|
|
|
// 构建请求URL,包含access_token
|
|
|
|
|
$queryUrl = 'https://api.weixin.qq.com/customservice/kfaccount/add?access_token=' . AccessToken::getAccessToken();
|
|
|
|
|
$queryAction = 'POST';
|
|
|
|
|
// 创建模板数组
|
|
|
|
|
$template = array();
|
|
|
|
|
$template['kf_account'] = $kfAccount;
|
|
|
|
|
$template['nickname'] = $nickname;
|
|
|
|
|
$template['password'] = $password;
|
|
|
|
|
// 将模板数组转换为JSON格式
|
|
|
|
|
$template = json_encode($template);
|
|
|
|
|
// 使用Curl类发送POST请求
|
|
|
|
|
return Curl::callWebServer($queryUrl, $template, $queryAction);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -46,13 +50,17 @@ class CustomService
|
|
|
|
|
*/
|
|
|
|
|
public function editAccount($kfAccount, $nickname, $password)
|
|
|
|
|
{
|
|
|
|
|
// 构建请求URL,包含access_token
|
|
|
|
|
$queryUrl = 'https://api.weixin.qq.com/customservice/kfaccount/update?access_token=' . AccessToken::getAccessToken();
|
|
|
|
|
$queryAction = 'POST';
|
|
|
|
|
// 创建模板数组
|
|
|
|
|
$template = array();
|
|
|
|
|
$template['kf_account'] = $kfAccount;
|
|
|
|
|
$template['nickname'] = $nickname;
|
|
|
|
|
$template['password'] = $password;
|
|
|
|
|
// 将模板数组转换为JSON格式
|
|
|
|
|
$template = json_encode($template);
|
|
|
|
|
// 使用Curl类发送POST请求
|
|
|
|
|
return Curl::callWebServer($queryUrl, $template, $queryAction);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -65,11 +73,15 @@ class CustomService
|
|
|
|
|
*/
|
|
|
|
|
public function delAccount($kfAccount)
|
|
|
|
|
{
|
|
|
|
|
// 构建请求URL,包含access_token
|
|
|
|
|
$queryUrl = 'https://api.weixin.qq.com/customservice/kfaccount/del?access_token=' . AccessToken::getAccessToken();
|
|
|
|
|
$queryAction = 'POST';
|
|
|
|
|
// 创建模板数组
|
|
|
|
|
$template = array();
|
|
|
|
|
$template['kf_account'] = $kfAccount;
|
|
|
|
|
// 将模板数组转换为JSON格式
|
|
|
|
|
$template = json_encode($template);
|
|
|
|
|
// 使用Curl类发送POST请求
|
|
|
|
|
return Curl::callWebServer($queryUrl, $template, $queryAction);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -81,8 +93,10 @@ class CustomService
|
|
|
|
|
*/
|
|
|
|
|
public function getAccountList()
|
|
|
|
|
{
|
|
|
|
|
// 构建请求URL,包含access_token
|
|
|
|
|
$queryUrl = 'https://api.weixin.qq.com/cgi-bin/customservice/getkflist?access_token=' . AccessToken::getAccessToken();
|
|
|
|
|
$queryAction = 'GET';
|
|
|
|
|
// 使用Curl类发送GET请求
|
|
|
|
|
return Curl::callWebServer($queryUrl, '', $queryAction);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -97,12 +111,16 @@ class CustomService
|
|
|
|
|
*/
|
|
|
|
|
public function setAccountImage($kfAccount, $imagePath)
|
|
|
|
|
{
|
|
|
|
|
// 检查头像文件是否存在
|
|
|
|
|
if (!file_exists($imagePath)) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
// 构建请求URL,包含access_token和kf_account
|
|
|
|
|
$queryUrl = 'http://api.weixin.qq.com/customservice/kfaccount/uploadheadimg?access_token=' . AccessToken::getAccessToken() . '&kf_account=' . $kfAccount;
|
|
|
|
|
// 创建数据数组
|
|
|
|
|
$data = array();
|
|
|
|
|
$data['media'] = '@' . $imagePath;
|
|
|
|
|
// 使用Curl类发送POST请求,设置multipart为1表示发送文件
|
|
|
|
|
return Curl::callWebServer($queryUrl, $data, 'POST', 1, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -120,16 +138,21 @@ class CustomService
|
|
|
|
|
*/
|
|
|
|
|
public function getRecord($startTime, $endTime, $pageIndex = 1, $pageSize = 1000, $openId = '')
|
|
|
|
|
{
|
|
|
|
|
// 构建请求URL,包含access_token
|
|
|
|
|
$queryUrl = 'https://api.weixin.qq.com/cgi-bin/customservice/getrecord?access_token=' . AccessToken::getAccessToken();
|
|
|
|
|
$queryAction = 'POST';
|
|
|
|
|
// 创建模板数组
|
|
|
|
|
$template = array();
|
|
|
|
|
$template['starttime'] = $startTime;
|
|
|
|
|
$template['endtime'] = $endTime;
|
|
|
|
|
$template['openid'] = $openId;
|
|
|
|
|
$template['pagesize'] = $pageSize;
|
|
|
|
|
$template['pageindex'] = $pageIndex;
|
|
|
|
|
// 将模板数组转换为JSON格式
|
|
|
|
|
$template = json_encode($template);
|
|
|
|
|
// 使用Curl类发送POST请求
|
|
|
|
|
$result = Curl::callWebServer($queryUrl, $template, $queryAction);
|
|
|
|
|
// 返回聊天记录列表
|
|
|
|
|
return isset($result['recordlist']) ? $result['recordlist'] : array();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|