You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
65 lines
2.8 KiB
65 lines
2.8 KiB
2 months ago
|
<?php
|
||
|
namespace LaneWeChat\Core;
|
||
|
|
||
|
Class CustomService{
|
||
|
public function addAccount($kfAccount, $nickname, $password){
|
||
|
$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;
|
||
|
$template = json_encode($template);
|
||
|
return Curl::callWebServer($queryUrl, $template, $queryAction);
|
||
|
}
|
||
|
|
||
|
public function editAccount($kfAccount, $nickname, $password){
|
||
|
$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;
|
||
|
$template = json_encode($template);
|
||
|
return Curl::callWebServer($queryUrl, $template, $queryAction);
|
||
|
}
|
||
|
|
||
|
public function delAccount($kfAccount){
|
||
|
$queryUrl = 'https://api.weixin.qq.com/customservice/kfaccount/del?access_token=' . AccessToken::getAccessToken();
|
||
|
$queryAction = 'POST';
|
||
|
$template = array();
|
||
|
$template['kf_account'] = $kfAccount;
|
||
|
$template = json_encode($template);
|
||
|
return Curl::callWebServer($queryUrl, $template, $queryAction);
|
||
|
}
|
||
|
|
||
|
public function getAccountList(){
|
||
|
$queryUrl = 'https://api.weixin.qq.com/cgi-bin/customservice/getkflist?access_token=' . AccessToken::getAccessToken();
|
||
|
$queryAction = 'GET';
|
||
|
return Curl::callWebServer($queryUrl, '', $queryAction);
|
||
|
}
|
||
|
|
||
|
public function setAccountImage($kfAccount, $imagePath){
|
||
|
if(!file_exists($imagePath)){
|
||
|
return false;
|
||
|
}
|
||
|
$queryUrl = 'http://api.weixin.qq.com/customservice/kfaccount/uploadheadimg?access_token=' . AccessToken::getAccessToken() . '&kf_account=' . $kfAccount;
|
||
|
$data = array();
|
||
|
$data['media'] = '@' . $imagePath;
|
||
|
return Curl::callWebServer($queryUrl, $data, 'POST', 1 , 0);
|
||
|
}
|
||
|
|
||
|
public function getRecord($startTime, $endTime, $pageIndex=1, $pageSize=1000, $openId=''){
|
||
|
$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;
|
||
|
$template = json_encode($template);
|
||
|
$result = Curl::callWebServer($queryUrl, $template, $queryAction);
|
||
|
return isset($result['recordlist']) ? $result['recordlist'] : array();
|
||
|
}
|
||
|
}
|