issue #82 增加邀请成员关注接口

This commit is contained in:
Daniel Qian 2015-01-24 14:51:57 +08:00
parent b921490253
commit b43a62c3a6
2 changed files with 24 additions and 0 deletions

View File

@ -315,6 +315,18 @@ public interface WxCpService {
*/
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

View File

@ -357,6 +357,18 @@ public class WxCpServiceImpl implements WxCpService {
}
}
@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);