|
|
|
@ -4,14 +4,19 @@ import com.taobao.api.ApiException;
|
|
|
|
|
import com.taobao.api.DefaultTaobaoClient;
|
|
|
|
|
import com.taobao.api.TaobaoClient;
|
|
|
|
|
import com.taobao.api.domain.Userinfos;
|
|
|
|
|
import com.taobao.api.request.OpenimCustmsgPushRequest;
|
|
|
|
|
import com.taobao.api.request.OpenimUsersAddRequest;
|
|
|
|
|
import com.taobao.api.request.OpenimUsersUpdateRequest;
|
|
|
|
|
import com.taobao.api.response.OpenimCustmsgPushResponse;
|
|
|
|
|
import com.taobao.api.response.OpenimUsersAddResponse;
|
|
|
|
|
import com.taobao.api.response.OpenimUsersUpdateResponse;
|
|
|
|
|
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Collections;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -23,10 +28,10 @@ public class OpenimClient {
|
|
|
|
|
Logger logger = LoggerFactory.getLogger(getClass());
|
|
|
|
|
private final String appkey = "24960261";
|
|
|
|
|
private final String secret = "7639427973bd671be15c9d0c1e9c90b4";
|
|
|
|
|
private final String add_user="https://eco.taobao.com/router/rest";
|
|
|
|
|
private final String url = "https://eco.taobao.com/router/rest";
|
|
|
|
|
|
|
|
|
|
public void addUser() {
|
|
|
|
|
TaobaoClient client = new DefaultTaobaoClient(add_user, appkey, secret);
|
|
|
|
|
TaobaoClient client = new DefaultTaobaoClient(url, appkey, secret);
|
|
|
|
|
OpenimUsersAddRequest req = new OpenimUsersAddRequest();
|
|
|
|
|
List<Userinfos> list2 = new ArrayList<>();
|
|
|
|
|
Userinfos obj3 = new Userinfos();
|
|
|
|
@ -59,8 +64,62 @@ private final String add_user="https://eco.taobao.com/router/rest";
|
|
|
|
|
System.out.println(rsp.getBody());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void main(String[] args) {
|
|
|
|
|
OpenimClient asd = new OpenimClient();
|
|
|
|
|
asd.addUser();
|
|
|
|
|
public void updateUser() {
|
|
|
|
|
TaobaoClient client = new DefaultTaobaoClient(url, appkey, secret);
|
|
|
|
|
OpenimUsersUpdateRequest req = new OpenimUsersUpdateRequest();
|
|
|
|
|
List<Userinfos> list2 = new ArrayList<Userinfos>();
|
|
|
|
|
Userinfos obj3 = new Userinfos();
|
|
|
|
|
list2.add(obj3);
|
|
|
|
|
obj3.setNick("king");
|
|
|
|
|
obj3.setIconUrl("http://xxx.com/xxx");
|
|
|
|
|
obj3.setEmail("uid@taobao.com");
|
|
|
|
|
obj3.setMobile("18600000000");
|
|
|
|
|
obj3.setTaobaoid("tbnick123");
|
|
|
|
|
obj3.setUserid("imuser123");
|
|
|
|
|
obj3.setPassword("xxxxxx");
|
|
|
|
|
obj3.setRemark("demo");
|
|
|
|
|
obj3.setExtra("{}");
|
|
|
|
|
obj3.setCareer("demo");
|
|
|
|
|
obj3.setVip("{}");
|
|
|
|
|
obj3.setAddress("demo");
|
|
|
|
|
obj3.setName("demo");
|
|
|
|
|
obj3.setAge(123L);
|
|
|
|
|
obj3.setGender("M");
|
|
|
|
|
obj3.setWechat("demo");
|
|
|
|
|
obj3.setQq("demo");
|
|
|
|
|
obj3.setWeibo("demo");
|
|
|
|
|
req.setUserinfos(list2);
|
|
|
|
|
OpenimUsersUpdateResponse rsp = null;
|
|
|
|
|
try {
|
|
|
|
|
rsp = client.execute(req);
|
|
|
|
|
} catch (ApiException e) {
|
|
|
|
|
logger.info("openim update user fail", e);
|
|
|
|
|
}
|
|
|
|
|
System.out.println(rsp.getBody());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void pushMsg(){
|
|
|
|
|
TaobaoClient client = new DefaultTaobaoClient(url, appkey, secret);
|
|
|
|
|
OpenimCustmsgPushRequest req = new OpenimCustmsgPushRequest();
|
|
|
|
|
OpenimCustmsgPushRequest.CustMsg obj1 = new OpenimCustmsgPushRequest.CustMsg();
|
|
|
|
|
obj1.setFromUser("user_sender");
|
|
|
|
|
obj1.setToAppkey("0");
|
|
|
|
|
obj1.setToUsers(Collections.singletonList("user1"));
|
|
|
|
|
obj1.setSummary("客户端最近消息里面显示的消息摘要");
|
|
|
|
|
obj1.setData("push payload");
|
|
|
|
|
obj1.setAps("{\"alert\":\"ios apns push\"}");
|
|
|
|
|
obj1.setApnsParam("apns推送的附带数据");
|
|
|
|
|
obj1.setInvisible(0L);
|
|
|
|
|
obj1.setFromNick("sender_nick");
|
|
|
|
|
obj1.setFromTaobao(0L);
|
|
|
|
|
req.setCustmsg(obj1);
|
|
|
|
|
OpenimCustmsgPushResponse rsp = null;
|
|
|
|
|
try {
|
|
|
|
|
rsp = client.execute(req);
|
|
|
|
|
} catch (ApiException e) {
|
|
|
|
|
logger.info("openim push msg fail", e);
|
|
|
|
|
}
|
|
|
|
|
System.out.println(rsp.getBody());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|