11
11
* Created by Binary Wang on 2016/7/21.
12
12
*/
13
13
public class WxMpMenuServiceImpl implements WxMpMenuService {
14
+ private static final String API_URL_PREFIX = "https://api.weixin.qq.com/cgi-bin/menu" ;
14
15
15
16
private WxMpService wxMpService ;
16
17
@@ -21,29 +22,29 @@ public WxMpMenuServiceImpl(WxMpService wxMpService) {
21
22
@ Override
22
23
public void menuCreate (WxMenu menu ) throws WxErrorException {
23
24
if (menu .getMatchRule () != null ) {
24
- String url = "https://api.weixin.qq.com/cgi-bin/menu /addconditional" ;
25
+ String url = API_URL_PREFIX + " /addconditional" ;
25
26
this .wxMpService .execute (new SimplePostRequestExecutor (), url , menu .toJson ());
26
27
} else {
27
- String url = "https://api.weixin.qq.com/cgi-bin/menu /create" ;
28
+ String url = API_URL_PREFIX + " /create" ;
28
29
this .wxMpService .execute (new SimplePostRequestExecutor (), url , menu .toJson ());
29
30
}
30
31
}
31
32
32
33
@ Override
33
34
public void menuDelete () throws WxErrorException {
34
- String url = "https://api.weixin.qq.com/cgi-bin/menu /delete" ;
35
+ String url = API_URL_PREFIX + " /delete" ;
35
36
this .wxMpService .execute (new SimpleGetRequestExecutor (), url , null );
36
37
}
37
38
38
39
@ Override
39
40
public void menuDelete (String menuid ) throws WxErrorException {
40
- String url = "https://api.weixin.qq.com/cgi-bin/menu /delconditional" ;
41
+ String url = API_URL_PREFIX + " /delconditional" ;
41
42
this .wxMpService .execute (new SimpleGetRequestExecutor (), url , "menuid=" + menuid );
42
43
}
43
44
44
45
@ Override
45
46
public WxMenu menuGet () throws WxErrorException {
46
- String url = "https://api.weixin.qq.com/cgi-bin/menu /get" ;
47
+ String url = API_URL_PREFIX + " /get" ;
47
48
try {
48
49
String resultContent = this .wxMpService .execute (new SimpleGetRequestExecutor (), url , null );
49
50
return WxMenu .fromJson (resultContent );
@@ -58,7 +59,7 @@ public WxMenu menuGet() throws WxErrorException {
58
59
59
60
@ Override
60
61
public WxMenu menuTryMatch (String userid ) throws WxErrorException {
61
- String url = "https://api.weixin.qq.com/cgi-bin/menu /trymatch" ;
62
+ String url = API_URL_PREFIX + " /trymatch" ;
62
63
try {
63
64
String resultContent = this .wxMpService .execute (new SimpleGetRequestExecutor (), url , "user_id=" + userid );
64
65
return WxMenu .fromJson (resultContent );
0 commit comments