/** * 发送消息 * * @param string $openId * * @return bool */ public function to($openId) { if (empty($this->message)) { throw new Exception('未设置要发送的消息'); } $this->message->to = $openId; return $this->http->jsonPost(self::API_MESSAGE_SEND, $this->message->buildForStaff()); }
/** * 发送消息 * * @param string $openId * * @return boolean */ public function to($openId) { if (empty($this->message)) { throw new Exception("未设置要发送的消息"); } $this->message->to = $openId; Wechat::request('POST', self::API_MESSAGE_SEND, $this->message->buildForStaff()); return true; }
/** * 发送消息 * * @param string $openId * * @return bool */ public function totag($tagid, $agentid = 1) { if (empty($this->message)) { throw new Exception('未设置要发送的消息'); } $this->message->totag = $tagid; $this->message->agentid = $agentid; $message_body = $this->message->buildForStaff(); return $this->http->jsonPost(self::API_MESSAGE_SEND, $message_body); }
/** * 预览. * * @param string $openId 接收消息用户对应该公众号的openid * @param string $type 接收消息用户的类型 * * @return bool */ public function preview($openId, $type = self::PREVIEW_BY_OPENID) { $this->message->to = $openId; return $this->http->jsonPost(self::API_PREVIEW, $this->message->buildForBroadcastPreview($type)); }