-
Notifications
You must be signed in to change notification settings - Fork 1
/
messages.go
54 lines (45 loc) · 1.17 KB
/
messages.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// Copyright 2015 The Yang Gui AUTHORS. All rights reserved.
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package easemob
import (
"net/http"
)
/**
* MessageService handles communication with the message related methods of
* the Easemo API
*
* Easemob API docs: http://docs.easemob.com/doku.php?id=start:100serverintegration:50messages
*/
type MessagesService struct {
client *Client
}
/**
* Send text message to users
*
* http://docs.easemob.com/doku.php?id=start:100serverintegration:50messages#发送文本消息
*/
func (s *MessagesService) SendTextMessagesToUsers(from string, text string,
userIds ...string) (*Response, error) {
var (
err error
putOptions *MessagePutOptions
path string
req *http.Request
resp *Response
)
putOptions = &MessagePutOptions{
TargetType: "users",
Target: userIds,
Msg: &MessageType{Type: "txt", Msg: text},
From: from,
}
path = "messages"
req, err = s.client.NewRequest("POST", path, putOptions)
if err != nil {
return nil, err
}
resp, err = s.client.Do(req)
return resp, err
}