新增邀请成员关注接口
This commit is contained in:
parent
d5b1f4e432
commit
e113bc3af0
@ -154,4 +154,8 @@
|
|||||||
|
|
||||||
+ **weixin4j-base**: 重构token实现机制
|
+ **weixin4j-base**: 重构token实现机制
|
||||||
|
|
||||||
+ **weixin4j-base**: 新增JSTICKET支持
|
+ **weixin4j-base**: 新增JSTICKET支持
|
||||||
|
|
||||||
|
* 2015-01-15
|
||||||
|
|
||||||
|
+ **weixin4j-qy**: 新增邀请成员关注接口
|
||||||
@ -1,6 +1,6 @@
|
|||||||
# \u6d4b\u8bd5\u4e4b\u7528 \u6b63\u5f0f\u73af\u5883\u4e0bcopy\u4e00\u4efd\u5230classpath
|
# \u6d4b\u8bd5\u4e4b\u7528 \u6b63\u5f0f\u73af\u5883\u4e0bcopy\u4e00\u4efd\u5230classpath
|
||||||
# \u516c\u4f17\u53f7\u4fe1\u606f
|
# \u516c\u4f17\u53f7\u4fe1\u606f
|
||||||
account={"id":"wx4ab8f8de58159a57","secret":"1d4eb0f4bf556aaed539f30ed05ca795",\
|
account={"id":"wxb72a4f2dbf27b59d","secret":"7ecc93fa8662f518a39c037fd599e1f5",\
|
||||||
"token":"\u5f00\u653e\u8005\u7684token",\
|
"token":"\u5f00\u653e\u8005\u7684token",\
|
||||||
"encodingAesKey":"\u516c\u4f17\u53f7\u8bbe\u7f6e\u4e86\u52a0\u5bc6\u65b9\u5f0f\u4e14\u4e3a\u300c\u5b89\u5168\u6a21\u5f0f\u300d\u65f6\u9700\u8981\u586b\u5165",\
|
"encodingAesKey":"\u516c\u4f17\u53f7\u8bbe\u7f6e\u4e86\u52a0\u5bc6\u65b9\u5f0f\u4e14\u4e3a\u300c\u5b89\u5168\u6a21\u5f0f\u300d\u65f6\u9700\u8981\u586b\u5165",\
|
||||||
"mchId":"V3.x\u7248\u672c\u4e0b\u7684\u5fae\u4fe1\u5546\u6237\u53f7 \u670d\u52a1\u53f7\u652f\u4ed8\u65f6\u9700\u8981\u586b\u5165",\
|
"mchId":"V3.x\u7248\u672c\u4e0b\u7684\u5fae\u4fe1\u5546\u6237\u53f7 \u670d\u52a1\u53f7\u652f\u4ed8\u65f6\u9700\u8981\u586b\u5165",\
|
||||||
|
|||||||
@ -102,3 +102,7 @@ weixin4j-qy
|
|||||||
* 2015-01-04
|
* 2015-01-04
|
||||||
|
|
||||||
+ **weixin4j-qy-api**: 新增批量删除员工接口
|
+ **weixin4j-qy-api**: 新增批量删除员工接口
|
||||||
|
|
||||||
|
* 2015-01-15
|
||||||
|
|
||||||
|
+ **weixin4j-qy-api**: 新增邀请成员关注接口
|
||||||
|
|||||||
@ -67,3 +67,7 @@ weixin.properties说明
|
|||||||
* 2015-01-04
|
* 2015-01-04
|
||||||
|
|
||||||
+ 新增批量删除员工接口
|
+ 新增批量删除员工接口
|
||||||
|
|
||||||
|
* 2015-01-15
|
||||||
|
|
||||||
|
+ 新增邀请成员关注接口
|
||||||
|
|||||||
@ -11,6 +11,7 @@ import com.foxinmy.weixin4j.qy.api.UserApi;
|
|||||||
import com.foxinmy.weixin4j.qy.model.Department;
|
import com.foxinmy.weixin4j.qy.model.Department;
|
||||||
import com.foxinmy.weixin4j.qy.model.Tag;
|
import com.foxinmy.weixin4j.qy.model.Tag;
|
||||||
import com.foxinmy.weixin4j.qy.model.User;
|
import com.foxinmy.weixin4j.qy.model.User;
|
||||||
|
import com.foxinmy.weixin4j.qy.type.InviteType;
|
||||||
import com.foxinmy.weixin4j.qy.type.UserStatus;
|
import com.foxinmy.weixin4j.qy.type.UserStatus;
|
||||||
import com.foxinmy.weixin4j.token.FileTokenHolder;
|
import com.foxinmy.weixin4j.token.FileTokenHolder;
|
||||||
import com.foxinmy.weixin4j.token.TokenHolder;
|
import com.foxinmy.weixin4j.token.TokenHolder;
|
||||||
@ -240,6 +241,24 @@ public class WeixinProxy {
|
|||||||
return userApi.batchDeleteUser(userIds);
|
return userApi.batchDeleteUser(userIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 邀请成员关注(管理员须拥有该成员的查看权限)
|
||||||
|
*
|
||||||
|
* @param userId
|
||||||
|
* 成员ID
|
||||||
|
* @param tips
|
||||||
|
* 推送到微信上的提示语(只有认证号可以使用)。当使用微信推送时,该字段默认为“请关注XXX企业号”,邮件邀请时,该字段无效。
|
||||||
|
* @see com.foxinmy.weixin4j.qy.api.UserApi
|
||||||
|
* @return 调用结果
|
||||||
|
* @see <a
|
||||||
|
* href="http://qydev.weixin.qq.com/wiki/index.php?title=%E7%AE%A1%E7%90%86%E6%88%90%E5%91%98#.E9.82.80.E8.AF.B7.E6.88.90.E5.91.98.E5.85.B3.E6.B3.A8">邀请成员关注说明</a>
|
||||||
|
* @throws WeixinException
|
||||||
|
*/
|
||||||
|
public InviteType inviteUser(String userId, String tips)
|
||||||
|
throws WeixinException {
|
||||||
|
return userApi.inviteUser(userId, tips);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建标签(创建的标签属于管理组;默认为未加锁状态)
|
* 创建标签(创建的标签属于管理组;默认为未加锁状态)
|
||||||
*
|
*
|
||||||
|
|||||||
@ -3,6 +3,8 @@ package com.foxinmy.weixin4j.qy.api;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONArray;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
@ -11,6 +13,7 @@ import com.foxinmy.weixin4j.http.JsonResult;
|
|||||||
import com.foxinmy.weixin4j.http.Response;
|
import com.foxinmy.weixin4j.http.Response;
|
||||||
import com.foxinmy.weixin4j.model.Token;
|
import com.foxinmy.weixin4j.model.Token;
|
||||||
import com.foxinmy.weixin4j.qy.model.User;
|
import com.foxinmy.weixin4j.qy.model.User;
|
||||||
|
import com.foxinmy.weixin4j.qy.type.InviteType;
|
||||||
import com.foxinmy.weixin4j.qy.type.UserStatus;
|
import com.foxinmy.weixin4j.qy.type.UserStatus;
|
||||||
import com.foxinmy.weixin4j.token.TokenHolder;
|
import com.foxinmy.weixin4j.token.TokenHolder;
|
||||||
|
|
||||||
@ -232,11 +235,45 @@ public class UserApi extends QyApi {
|
|||||||
* href="http://qydev.weixin.qq.com/wiki/index.php?title=%E5%85%B3%E6%B3%A8%E4%B8%8E%E5%8F%96%E6%B6%88%E5%85%B3%E6%B3%A8">二次验证说明</a>
|
* href="http://qydev.weixin.qq.com/wiki/index.php?title=%E5%85%B3%E6%B3%A8%E4%B8%8E%E5%8F%96%E6%B6%88%E5%85%B3%E6%B3%A8">二次验证说明</a>
|
||||||
* @throws WeixinException
|
* @throws WeixinException
|
||||||
*/
|
*/
|
||||||
public JsonResult authsucc(String userid) throws WeixinException {
|
public JsonResult authsucc(String userId) throws WeixinException {
|
||||||
String user_authsucc_uri = getRequestUri("user_authsucc_uri");
|
String user_authsucc_uri = getRequestUri("user_authsucc_uri");
|
||||||
Token token = tokenHolder.getToken();
|
Token token = tokenHolder.getToken();
|
||||||
Response response = request.post(String.format(user_authsucc_uri,
|
Response response = request.post(String.format(user_authsucc_uri,
|
||||||
token.getAccessToken(), userid));
|
token.getAccessToken(), userId));
|
||||||
return response.getAsJsonResult();
|
return response.getAsJsonResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 邀请成员关注(管理员须拥有该成员的查看权限)
|
||||||
|
*
|
||||||
|
* @param userId
|
||||||
|
* 成员ID
|
||||||
|
* @param tips
|
||||||
|
* 推送到微信上的提示语(只有认证号可以使用)。当使用微信推送时,该字段默认为“请关注XXX企业号”,邮件邀请时,该字段无效。
|
||||||
|
* @return 调用结果
|
||||||
|
* @see <a
|
||||||
|
* href="http://qydev.weixin.qq.com/wiki/index.php?title=%E7%AE%A1%E7%90%86%E6%88%90%E5%91%98#.E9.82.80.E8.AF.B7.E6.88.90.E5.91.98.E5.85.B3.E6.B3.A8">邀请成员关注说明</a>
|
||||||
|
* @throws WeixinException
|
||||||
|
*/
|
||||||
|
public InviteType inviteUser(String userId, String tips)
|
||||||
|
throws WeixinException {
|
||||||
|
JSONObject obj = new JSONObject();
|
||||||
|
obj.put("userid", userId);
|
||||||
|
if (StringUtils.isBlank(tips)) {
|
||||||
|
obj.put("invite_tips", tips);
|
||||||
|
}
|
||||||
|
String invite_user_uri = getRequestUri("invite_user_uri");
|
||||||
|
Token token = tokenHolder.getToken();
|
||||||
|
Response response = request.post(
|
||||||
|
String.format(invite_user_uri, token.getAccessToken()),
|
||||||
|
obj.toJSONString());
|
||||||
|
int type = response.getAsJson().getIntValue("type");
|
||||||
|
if (type == 1) {
|
||||||
|
return InviteType.WEIXIN;
|
||||||
|
} else if (type == 2) {
|
||||||
|
return InviteType.EMAIL;
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -45,6 +45,8 @@ tag_get_user_uri={api_base_url}/tag/get?access_token=%s&tagid=%d
|
|||||||
tag_add_user_uri={api_base_url}/tag/addtagusers?access_token=%s
|
tag_add_user_uri={api_base_url}/tag/addtagusers?access_token=%s
|
||||||
# \u5220\u9664\u6807\u7b7e\u6210\u5458
|
# \u5220\u9664\u6807\u7b7e\u6210\u5458
|
||||||
tag_delete_user_uri={api_base_url}/tag/deltagusers?access_token=%s
|
tag_delete_user_uri={api_base_url}/tag/deltagusers?access_token=%s
|
||||||
|
# \u9080\u8bf7\u6210\u5458\u5173\u6ce8
|
||||||
|
invite_user_uri={api_base_url}/invite/send?access_token=%s
|
||||||
# \u4e0a\u4f20\u5a92\u4f53\u6587\u4ef6
|
# \u4e0a\u4f20\u5a92\u4f53\u6587\u4ef6
|
||||||
file_upload_uri={api_base_url}/media/upload?access_token=%s&type=%s
|
file_upload_uri={api_base_url}/media/upload?access_token=%s&type=%s
|
||||||
# \u4e0b\u8f7d\u5a92\u4f53\u6587\u4ef6
|
# \u4e0b\u8f7d\u5a92\u4f53\u6587\u4ef6
|
||||||
|
|||||||
@ -0,0 +1,13 @@
|
|||||||
|
package com.foxinmy.weixin4j.qy.type;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 邀请类型
|
||||||
|
* @className InviteType
|
||||||
|
* @author jy
|
||||||
|
* @date 2015年1月15日
|
||||||
|
* @since JDK 1.7
|
||||||
|
* @see
|
||||||
|
*/
|
||||||
|
public enum InviteType {
|
||||||
|
WEIXIN, EMAIL
|
||||||
|
}
|
||||||
@ -71,4 +71,9 @@ public class UserTest extends TokenTest {
|
|||||||
JsonResult result = userApi.deleteUser("u001");
|
JsonResult result = userApi.deleteUser("u001");
|
||||||
Assert.assertEquals("deleted", result.getDesc());
|
Assert.assertEquals("deleted", result.getDesc());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void invite()throws WeixinException{
|
||||||
|
userApi.inviteUser("11", null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user