-
Notifications
You must be signed in to change notification settings - Fork 147
/
client.go
32 lines (25 loc) · 863 Bytes
/
client.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
package semantic
import (
"github.com/ArtisanCloud/PowerLibs/v2/object"
"github.com/ArtisanCloud/PowerWeChat/v2/src/kernel"
"github.com/ArtisanCloud/PowerWeChat/v2/src/kernel/power"
)
type Client struct {
*kernel.BaseClient
}
// 语义接口
// https://developers.weixin.qq.com/doc/offiaccount/Intelligent_Interface/Natural_Language_Processing.html
func (comp *Client) Query(keyword string, categories string, optional *power.HashMap) (interface{}, error) {
config := (*comp.App).GetConfig()
params := &object.HashMap{
"query": keyword,
"category": categories,
"appid": config.GetString("app_id", ""),
}
objOptional, err := power.PowerHashMapToObjectHashMap(optional)
if err != nil {
return nil, err
}
params = object.MergeHashMap(params, objOptional)
return comp.HttpPostJson("semantic/semproxy/search", params, nil, nil, nil)
}