arg = [ // 把消息同步到 From_Account 在线终端和漫游上;消息不同步至 From_Account; 'SyncOtherMachine' => 1, //消息随机数(32位无符号整数) 'MsgRandom' => random_int(1, 4292967295), /** * 消息回调禁止开关,只对本条消息有效 * ForbidBeforeSendMsgCallback 表示禁止发消息前回调 * ForbidAfterSendMsgCallback 表示禁止发消息后回调 */ 'ForbidCallbackControl' => ['ForbidBeforeSendMsgCallback','ForbidAfterSendMsgCallback'], /** * 消息发送控制选项,是一个 String 数组,只对本条消息有效。 * "NoUnread"表示该条消息不计入未读数。 * "NoLastMsg"表示该条消息不更新会话列表。 * "WithMuteNotifications"表示该条消息的接收方对发送方设置的免打扰选项生效(默认不生效) */ 'SendMsgControl' => ['NoUnread','NoLastMsg','WithMuteNotifications'], 'MsgBody' => [ /** * 消息对象类型 * TIMTextElem(文本消息) * TIMLocationElem(位置消息) * TIMFaceElem(表情消息) * TIMCustomElem(自定义消息) * TIMSoundElem(语音消息) * TIMImageElem(图像消息) * TIMFileElem(文件消息) * TIMVideoFileElem(视频消息) */ 'MsgType' => "TIMTextElem", // 消息内容,对于每种 MsgType 用不同的 MsgContent 格式 'MsgContent' => null, ], /** * 消息自定义数据(云端保存,会发送到对端,程序卸载重装后还能拉取到) * 如聊天类型。json格式 * order_inquiry_id * inquiry_type * message_type 消息类型(1:系统发送 其余:用户发送) */ 'CloudCustomData' => "", ]; } /** * 发送消息 * @param array $arg * @return bool * @throws GuzzleException */ public function sendMessage(array $arg): bool { try { // 合并发送参数 $arg = array_merge($this->arg,$arg); Log::getInstance()->info(json_encode($arg,JSON_UNESCAPED_UNICODE)); $options = [ "json"=> $arg ]; $path = $this->config['base_url'] . $this->version . "/openim/sendmsg?" . $this->buildRequestParams(); $this->postRequest($path,$options); return true; }catch (\Exception $e) { throw new BusinessException($e->getMessage(), HttpEnumCode::SERVER_ERROR); } } }