wechat-php-sdk
wechat-php-sdk copied to clipboard
发送消息接口,建议增加一个agentid判断
public function sendMessage($data){
if (!$this->access_token && !$this->checkAuth()) return false;
// 此处添加
if (empty($data['agentid'])) {
$data['agentid'] = $this->agentid;
}
$result = $this->http_post(self::API_URL_PREFIX.self::MASS_SEND_URL.'access_token='.$this->access_token,self::json_encode($data));
if ($result)
{
$json = json_decode($result,true);
if (!$json || !empty($json['errcode']) || $json['errcode']!=0) {
$this->errCode = $json['errcode'];
$this->errMsg = $json['errmsg'];
return false;
}
return $json;
}
return false;
}
这是为何?
如果$data['agentid'] 不存在的话,就不能指定发送的是哪一个企业号