Skip to content

Commit

Permalink
issue #82 增加邀请成员关注接口
Browse files Browse the repository at this point in the history
  • Loading branch information
chanjarster committed Jan 24, 2015
1 parent b921490 commit b43a62c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,18 @@ public WxMediaUploadResult mediaUpload(String mediaType, String fileType, InputS
*/
public void tagRemoveUsers(String tagId, List<String> userIds) throws WxErrorException;

/**
* <pre>
* 邀请成员关注
* http://qydev.weixin.qq.com/wiki/index.php?title=管理成员#.E9.82.80.E8.AF.B7.E6.88.90.E5.91.98.E5.85.B3.E6.B3.A8
* </pre>
* @param userId 用户的userid
* @param inviteTips 推送到微信上的提示语(只有认证号可以使用)。当使用微信推送时,该字段默认为“请关注XXX企业号”,邮件邀请时,该字段无效。
* @return 1:微信邀请 2.邮件邀请
* @throws WxErrorException
*/
public int invite(String userId, String inviteTips) throws WxErrorException;

/**
* 当本Service没有实现某个API的时候,可以用这个,针对所有微信API中的GET请求
* @param url
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,18 @@ public String[] oauth2getUserInfo(String code) throws WxErrorException {
}
}

@Override
public int invite(String userId, String inviteTips) throws WxErrorException {
String url = "https://qyapi.weixin.qq.com/cgi-bin/invite/send";
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("userid", userId);
if (StringUtils.isNotEmpty(inviteTips)) {
jsonObject.addProperty("invite_tips", inviteTips);
}
String responseContent = execute(new SimplePostRequestExecutor(), url, jsonObject.toString());
JsonElement tmpJsonElement = Streams.parse(new JsonReader(new StringReader(responseContent)));
return tmpJsonElement.getAsJsonObject().get("type").getAsInt();
}

public String get(String url, String queryParam) throws WxErrorException {
return execute(new SimpleGetRequestExecutor(), url, queryParam);
Expand Down

0 comments on commit b43a62c

Please sign in to comment.