使用环信账号发送系统通知及消息提醒

package com.shangyu.utils;

import java.io.BufferedReader;

import java.io.IOException;

import java.io.InputStreamReader;

import java.io.UnsupportedEncodingException;

import java.util.ArrayList;

import java.util.HashMap;

import java.util.List;

import java.util.Map;

import org.apache.http.HttpEntity;

import org.apache.http.HttpResponse;

import org.apache.http.NameValuePair;

import org.apache.http.client.ClientProtocolException;

import org.apache.http.client.methods.CloseableHttpResponse;

import org.apache.http.client.methods.HttpDelete;

import org.apache.http.client.methods.HttpGet;

import org.apache.http.client.methods.HttpPost;

import org.apache.http.client.methods.HttpPut;

import org.apache.http.entity.StringEntity;

import org.apache.http.impl.client.CloseableHttpClient;

import org.apache.http.impl.client.DefaultHttpClient;

import org.apache.http.impl.client.HttpClients;

import org.apache.http.message.BasicNameValuePair;

import org.apache.http.util.EntityUtils;

import org.json.JSONObject;

import com.shangyu.core.utils.PropertyUtils;

public class SysUserHuanXinService{

private static String tokenurl = PropertyUtils.getPropertyValue("shangyu.properties", "hx_tokenurl");

private static String userurl = PropertyUtils.getPropertyValue("shangyu.properties", "hx_userurl");

private static String client_id = PropertyUtils.getPropertyValue("shangyu.properties", "hx_client_id");

private static String client_secret = PropertyUtils.getPropertyValue("shangyu.properties", "hx_client_secret");

private static String grant_type = PropertyUtils.getPropertyValue("shangyu.properties", "hx_grant_type");

private static String charset = PropertyUtils.getPropertyValue("shangyu.properties", "charset");

private static String msgurl = PropertyUtils.getPropertyValue("shangyu.properties", "hx_messagesurl");

/**

* 添加所有用户带环信服务器

*/

/* public  void addUsers() {

Map<String, Object> param = new HashMap<String, Object>();

SysUserService sysuser = SpringContextHelper.getBean(SysUserService.class);

System.out.println(sysuser);

List<SysUser> userlist = sysuser.findByMap(param);

System.out.println(userlist.size()+"==========");

for (SysUser sue : userlist) {

suhs.addHuanXinUser(sue.getUid(), sue.getPlainPassword(), sue.getRealName());

}

}*/

/**

*

* @author hekang

* @return strtoken

* @throws ClientProtocolException

* @throws IOException

*/

public static String getToken() throws ClientProtocolException, IOException{

Map<String,String> createMap = new HashMap<String,String>();

createMap.put("client_id", client_id);

createMap.put("client_secret", client_secret);

createMap.put("grant_type", grant_type);

HttpPost httpPost = new HttpPost(tokenurl);

List<NameValuePair> nvps = new ArrayList<NameValuePair>();

nvps.add(new BasicNameValuePair("Content-Type", "application/json"));

for(NameValuePair nameValuePair:nvps){

httpPost.addHeader(nameValuePair.getName(), nameValuePair.getValue());

}

try {

httpPost.setEntity(new StringEntity(JsonUtils.pojo2json(createMap), charset));

} catch (Exception e) {

e.printStackTrace();

System.out.println(e.getMessage());

}

HttpResponse httpResponse = new DefaultHttpClient().execute(httpPost);

String retSrc = EntityUtils.toString(httpResponse.getEntity());

JSONObject obj = new JSONObject(retSrc);

String strtoken = obj.get("access_token").toString();

return strtoken;

}

/**

* addHuanXinUser

* 描述:添加环信用户信息

* @author hekang

* @param uid

* @param PlainPassword

* @param realName

*/

public void addHuanXinUser(String uid, String PlainPassword, String realName){

Map<String,String> params = new HashMap<String,String>();

params.put("username", uid);

params.put("password", PlainPassword);

params.put("nickname", realName);

HttpPost httpPost = new HttpPost(userurl);

List<NameValuePair> nvps = new ArrayList<NameValuePair>();

nvps.add(new BasicNameValuePair("Content-Type", "application/json"));

String token;

try {

token = getToken();

System.out.println("---token----"+token);

nvps.add(new BasicNameValuePair("Authorization", "Bearer "+token));

} catch (ClientProtocolException e) {

e.printStackTrace();

System.out.println("--ClientProtocolException--"+e.getMessage());

} catch (IOException e) {

e.printStackTrace();

System.out.println("--IOException--"+e.getMessage());

}

for(NameValuePair nameValuePair:nvps){

httpPost.addHeader(nameValuePair.getName(), nameValuePair.getValue());

}

try {

httpPost.setEntity(new StringEntity(JsonUtils.pojo2json(params),"utf-8"));

} catch (Exception e) {

e.printStackTrace();

}

try {

HttpResponse httpResponse = new DefaultHttpClient().execute(httpPost);

if(httpResponse != null){

int statusCode = httpResponse.getStatusLine().getStatusCode();

if(statusCode == 200){

System.out.println("--add--");

}

}

String retSrc = EntityUtils.toString(httpResponse.getEntity());

System.out.println("---success---"+retSrc);

/* JSONObject json = new JSONObject(retSrc);

if("duplicate_unique_property_exists".equals(json.get("error").toString())){

System.out.println("---该用户已经存在---不允许再次添加-");

}*/

} catch (ClientProtocolException e) {

e.printStackTrace();

} catch (IOException e) {

e.printStackTrace();

}

System.out.println("-----add---end---success---");

}

/**

* deleteByuid

* 描述:删除环信用户

* @author hekang

* @param uid

*/

public void deleteByuid(String uid){

String token;

HttpResponse httpResponse;

HttpDelete httpdelete = new HttpDelete(userurl+"/"+uid);

List<NameValuePair> nvps = new ArrayList<NameValuePair>();

nvps.add(new BasicNameValuePair("Content-Type", "application/json"));

try {

token = getToken();

nvps.add(new BasicNameValuePair("Authorization", "Bearer "+token));

} catch (ClientProtocolException e1) {

e1.printStackTrace();

} catch (IOException e1) {

e1.printStackTrace();

}

for(NameValuePair nameValuePair:nvps){

httpdelete.addHeader(nameValuePair.getName(), nameValuePair.getValue());

}

try {

httpResponse = new DefaultHttpClient().execute(httpdelete);

if(httpResponse != null){

int statusCode = httpResponse.getStatusLine().getStatusCode();

if(statusCode == 200){

System.out.println("--del--");

}

}

String retSrc = EntityUtils.toString(httpResponse.getEntity());

System.out.println("----success----"+retSrc);

/* JSONObject json = new JSONObject(retSrc);

if("service_resource_not_found".equals(json.get("error").toString())){

System.out.println("--环信服务器不存在该用户--");

}*/

} catch (ClientProtocolException e) {

e.printStackTrace();

} catch (IOException e) {

e.printStackTrace();

}

System.out.println("---del---end---success---");

}

/**

* put

* 描述:更新环信昵称

* @author hekang

* @param uid

*/

public void putHuanXinUser(String uid,String password,String nickname){

System.out.println("--11uid--"+uid+"--password--"+password+"--nickname--"+nickname);

String token;

HttpPut httpput = new HttpPut(userurl+"/"+uid);

Map<String,String> params = new HashMap<String,String>();

//params.put("username", uid);

if(!"".equals(password) && password != null){

params.put("password", password);

}

if(!"".equals(nickname)){

params.put("nickname", nickname);

}

List<NameValuePair> nvps = new ArrayList<NameValuePair>();

nvps.add(new BasicNameValuePair("Content-Type", "application/json"));

try {

token = getToken();

nvps.add(new BasicNameValuePair("Authorization", "Bearer "+token));

} catch (ClientProtocolException e) {

e.printStackTrace();

System.out.println("--ClientProtocolException--"+e.getMessage());

} catch (IOException e) {

e.printStackTrace();

System.out.println("--IOException--"+e.getMessage());

}

for(NameValuePair nameValuePair:nvps){

httpput.addHeader(nameValuePair.getName(), nameValuePair.getValue());

}

DefaultHttpClient client = new DefaultHttpClient();

try {

httpput.setEntity(new StringEntity(JsonUtils.pojo2json(params),"utf-8"));

HttpResponse response = client.execute(httpput);

if(response != null){

int statusCode = response.getStatusLine().getStatusCode();

if(statusCode == 200){

System.out.println("--put--");

}

}

String retSrc = EntityUtils.toString(response.getEntity());

System.out.println("---success---"+retSrc);

} catch (UnsupportedEncodingException e) {

e.printStackTrace();

} catch (ClientProtocolException e) {

e.printStackTrace();

} catch (IOException e) {

e.printStackTrace();

}

}

/**

* get

* 描述:获取单个环信用户信息

* @author hekang

* @param uid

* 获取单个用户信息

*/

public void getHuanXinUser(String uid){

String token;

HttpResponse httpResponse;

HttpGet httpGet = new HttpGet(userurl+"/"+uid);

List<NameValuePair> nvps = new ArrayList<NameValuePair>();

nvps.add(new BasicNameValuePair("Content-Type", "application/json"));

try {

token = getToken();

nvps.add(new BasicNameValuePair("Authorization", "Bearer "+token));

} catch (ClientProtocolException e1) {

e1.printStackTrace();

} catch (IOException e1) {

e1.printStackTrace();

}

for(NameValuePair nameValuePair:nvps){

httpGet.addHeader(nameValuePair.getName(), nameValuePair.getValue());

}

try {

httpResponse = new DefaultHttpClient().execute(httpGet);

if(httpResponse != null){

int statusCode = httpResponse.getStatusLine().getStatusCode();

if(statusCode == 200){

System.out.println("--get--");

}

}

String retSrc = EntityUtils.toString(httpResponse.getEntity());

System.out.println("----success----"+retSrc);

/* JSONObject json = new JSONObject(retSrc);

if("service_resource_not_found".equals(json.get("error").toString())){

System.out.println("--环信服务器不存在该用户--");

}*/

} catch (ClientProtocolException e) {

e.printStackTrace();

} catch (IOException e) {

e.printStackTrace();

}

}

/**

* @author hekang

* 获取该app下的所有环信用户

*/

public String getAllHuanXinUsers(){

String token;

HttpResponse httpResponse;

BufferedReader in = null;

String content = null;

HttpGet httpGet = new HttpGet(userurl);

List<NameValuePair> nvps = new ArrayList<NameValuePair>();

nvps.add(new BasicNameValuePair("Content-Type", "application/json"));

try {

token = getToken();

nvps.add(new BasicNameValuePair("Authorization", "Bearer "+token));

} catch (ClientProtocolException e1) {

e1.printStackTrace();

} catch (IOException e1) {

e1.printStackTrace();

}

for(NameValuePair nameValuePair:nvps){

httpGet.addHeader(nameValuePair.getName(), nameValuePair.getValue());

}

try {

httpResponse = new DefaultHttpClient().execute(httpGet);

in = new BufferedReader(new InputStreamReader(httpResponse.getEntity()

.getContent()));

StringBuffer sb = new StringBuffer("");

String line = "";

String NL = System.getProperty("line.separator");

while ((line = in.readLine()) != null) {

sb.append(line + NL);

}

in.close();

content = sb.toString();

System.out.println("---allusers---"+content);

} catch (ClientProtocolException e) {

e.printStackTrace();

} catch (IOException e) {

e.printStackTrace();

}finally {

if (in != null) {

try {

in.close();// 最后要关闭BufferedReader

} catch (Exception e) {

e.printStackTrace();

}

}

}

return content;

}

/**

*

* @Title: addMessages

* @Description: 发送消息

* @param     参数

* @return void    返回类型

* @throws

*/

public static void addMessages(String msg, String[] newUserIds, String userid){

Map<String, Object> param = new HashMap<String, Object>();

String result = null;

// 创建默认的httpClient实例.

CloseableHttpClient httpclient = HttpClients.createDefault();

//创建httpPost

HttpPost httpPost = new HttpPost(msgurl);

try {

//String[] userArr = new String[]{"4028803557ad88a10157ada6bdb4001f","4028803557ad88a10157ada73ac40020","4028803557ad88a10157ad9d44130013"};

Map<String, Object> msgmap = new HashMap<String, Object>();

msgmap.put("type", "txt");

msgmap.put("msg", msg);

//msgmap.put("msg", "hello from rest! 道路比较滑,注意安全!");

param.put("target_type", "users");//users 给用户发消息。chatgroups: 给群发消息,chatrooms: 给聊天室发消息

param.put("from", userid);//表示消息发送者。无此字段Server会默认设置为"from":"admin",有from字段但值为空串("")时请求失败

param.put("target", newUserIds);//接收人数组,数组长度建议不大于20

param.put("msg", msgmap);//消息类型及文本

httpPost.addHeader("Content-Type", "application/json");

httpPost.addHeader("Authorization", "Bearer "+getToken().toString());

httpPost.setEntity(new StringEntity(JsonUtils.pojo2json(param), charset));

CloseableHttpResponse httpResponse = httpclient.execute(httpPost);

try {

if(httpResponse.getStatusLine().getStatusCode() == 200){

System.out.println("--addmessges--success");

}

HttpEntity entity = httpResponse.getEntity();

if(entity != null){

result = EntityUtils.toString(entity, charset);

}

} finally {

httpResponse.close();

}

} catch (Exception e) {

e.printStackTrace();

}finally {

// 关闭连接,释放资源

try {

httpclient.close();

} catch (IOException e) {

}

}

System.out.println("---result---"+result);

}

public static void main(String[] args) {

SysUserHuanXinService sys = new SysUserHuanXinService();

//sys.putHuanXinUser("12", "1234567890", "admin");

//sys.addMessages("hello ", args, "12");

}

}

注释:

配置文件:shangyu.properties

#huanxin_message

hx_client_id=YXA75UxWkI34Eea-M5V9ogKt0Q

hx_client_secret=YXA7ahOOOn95cT-LC0_jvc5qisc9LKU

hx_grant_type=client_credentials

hx_tokenurl=https://a1.easemob.com/97501822/officeautomationsyste/token

hx_userurl=https://a1.easemob.com/97501822/officeautomationsyste/users

hx_messagesurl=https://a1.easemob.com/97501722/officeautomationsystem/messages

charset=UTF-8

apply_admin=sykjapplay0101

请假通知与审批提醒:

//环信申请通知

private static String apply_admin = PropertyUtils.getPropertyValue("shangyu.properties", "apply_admin");

String[] newUserIds = new String[]{auditor};

if(StringUtils.isEmpty(apply_admin)){

apply_admin = session.getUserId();

}

SysUserHuanXinService.addMessages("请假申请", newUserIds, apply_admin);//申请

//公告通知

String[] userId = entity.getNotifyUsers();//获取选中的所有接受通知的人

String userIdsString = userId[0];

String[] userIds = userIdsString.split(",");

List<String> userIdList = new ArrayList<String>();

for (int i = 0; i < userIds.length; i++) {

if (userIds[i].indexOf("user") >= 0) {

String newUserId = userIds[i].substring(userIds[i].indexOf("|") + 1, userIds[i].length());

userIdList.add(newUserId);

}

}

String[] newUserIds = new String[userIdList.size()];

userIdList.toArray(newUserIds);//集合转数组(并且指定数组类型)

//newUserIds = userIdList.toArray(newUserIds);

SysUserHuanXinService.addMessages(entity.getContent(), newUserIds, admin.getUser().getUid());//newUserIds必须是数组

使用到的工具类有:--------JsonUtils工具类----------

package com.shangyu.utils;

import java.util.HashMap;

import java.util.Iterator;

import java.util.List;

import java.util.Map;

import org.json.JSONObject;

import net.minidev.json.JSONArray;

import net.minidev.json.JSONValue;

public class JsonUtils {

public static String pojo2json(Object pojo){

String jsonStr = JSONValue.toJSONString(pojo);

return jsonStr;

}

/**

* json

* @param json

* @return

*/

public static Object json2pojo(String json){

Object obj = null;

try {

obj = JSONValue.parse(json);

} catch (Exception e) {

e.printStackTrace();

}

return obj;

}

/**

* list

* @param <T>

* @param list

* @return

*/

public static <T> String list2json(List<T> list){

String jsonStr = JSONValue.toJSONString(list);

return jsonStr;

}

/**

* json

* @param json

* @return

*/

public static List json2list(String json){

Object obj=JSONValue.parse(json);

JSONArray array=(JSONArray)obj;

return array;

}

public static Map jsonToObject(String jsonStr) throws Exception {

JSONObject jsonObj = new JSONObject(jsonStr);

Iterator<String> nameItr = jsonObj.keys();

String name;

Map<String, String> outMap = new HashMap<String, String>();

while (nameItr.hasNext()) {

name = nameItr.next();

outMap.put(name, jsonObj.getString(name));

}

return outMap;

}

}

//-------------------PropertyUtils工具类------------------------------

package com.shangyu.core.utils;

import java.io.File;

import java.io.FileInputStream;

import java.io.FileNotFoundException;

import java.io.IOException;

import java.io.InputStream;

import java.util.ArrayList;

import java.util.Collections;

import java.util.Enumeration;

import java.util.HashMap;

import java.util.List;

import java.util.Map;

import java.util.Properties;

import java.util.Set;

import java.util.TreeSet;

import org.springframework.beans.BeansException;

import org.springframework.beans.factory.BeanFactory;

import org.springframework.beans.factory.BeanFactoryAware;

import org.springframework.util.ResourceUtils;

/**

* @ClassName: PropertyUtils

* @Description: TODO(属性操作工具类)

* @author xiaowei

* @date 2014年10月16日 下午3:29:00

*

*/

public class PropertyUtils implements BeanFactoryAware {

public List<String> getList(String prefix) {

if (properties == null || prefix == null) {

return Collections.emptyList();

}

List<String> list = new ArrayList<String>();

Enumeration<?> en = properties.propertyNames();

String key;

while (en.hasMoreElements()) {

key = (String) en.nextElement();

if (key.startsWith(prefix)) {

list.add(properties.getProperty(key));

}

}

return list;

}

public Set<String> getSet(String prefix) {

if (properties == null || prefix == null) {

return Collections.emptySet();

}

Set<String> set = new TreeSet<String>();

Enumeration<?> en = properties.propertyNames();

String key;

while (en.hasMoreElements()) {

key = (String) en.nextElement();

if (key.startsWith(prefix)) {

set.add(properties.getProperty(key));

}

}

return set;

}

public Map<String, String> getMap(String prefix) {

if (properties == null || prefix == null) {

return Collections.emptyMap();

}

Map<String, String> map = new HashMap<String, String>();

Enumeration<?> en = properties.propertyNames();

String key;

int len = prefix.length();

while (en.hasMoreElements()) {

key = (String) en.nextElement();

if (key.startsWith(prefix)) {

map.put(key.substring(len), properties.getProperty(key));

}

}

return map;

}

public Properties getProperties(String prefix) {

Properties props = new Properties();

if (properties == null || prefix == null) {

return props;

}

Enumeration<?> en = properties.propertyNames();

String key;

int len = prefix.length();

while (en.hasMoreElements()) {

key = (String) en.nextElement();

if (key.startsWith(prefix)) {

props.put(key.substring(len), properties.getProperty(key));

}

}

return props;

}

public String getPropertiesString(String prefix) {

String property = "";

if (properties == null || prefix == null) {

return property;

}

Enumeration<?> en = properties.propertyNames();

String key;

while (en.hasMoreElements()) {

key = (String) en.nextElement();

if (key.equals(prefix)) {

return properties.getProperty(key);

}

}

return property;

}

public Map<String, Object> getBeanMap(String prefix) {

Map<String, String> keyMap = getMap(prefix);

if (keyMap.isEmpty()) {

return Collections.emptyMap();

}

Map<String, Object> resultMap = new HashMap<String, Object>(keyMap.size());

String key, value;

for (Map.Entry<String, String> entry : keyMap.entrySet()) {

key = entry.getKey();

value = entry.getValue();

resultMap.put(key, beanFactory.getBean(value, Object.class));

}

return resultMap;

}

public static Properties getProperties(File file) {

Properties props = new Properties();

InputStream in;

try {

in = new FileInputStream(file);

props.load(in);

} catch (FileNotFoundException e) {

e.printStackTrace();

} catch (IOException e) {

e.printStackTrace();

}

return props;

}

public static String getPropertyValue(String filename, String key) {

File resource;

try {

resource = ResourceUtils.getFile("classpath:config/"+filename);

Properties props = getProperties(resource);

return (String) props.get(key);

} catch (FileNotFoundException e) {

e.printStackTrace();

}

return null;

}

private BeanFactory beanFactory;

private Properties properties;

public void setProperties(Properties properties) {

this.properties = properties;

}

public void setBeanFactory(BeanFactory beanFactory) throws BeansException {

this.beanFactory = beanFactory;

}

}

时间: 12-13

使用环信账号发送系统通知及消息提醒的相关文章

微信公众号教程(9)公众账号发送欢迎图文消息

第十章 公众账号发送欢迎图文消息 昨天已经讲了如何实现用户订阅公众账号时发送欢迎词,但这个貌似体现不出开发模式的优势啊,我用编辑模式做不是更加简单嘛,那么今天就来个升级版的欢迎词吧.先看最后的效果,如下图: 当用户关注公众账号时自动回复一个多图文消息,每个图文消息可以对应一篇文章或者自己网站的某个网页,用户点击就可以查看,是不是非常棒,特别适合一些企业用来做公司业务介绍.现在就教大家如何实现,顺便就可以把图文消息的回复讲了. 一.使用SAE的分布式存储服务 在编辑模式里做图文消息回复时,直接通过

环信SDK

初始化 SDK 第 1 步:引入相关头文件 #import “EMSDK.h”. 第 2 步:在工程的 AppDelegate 中的以下方法中,调用 SDK 对应方法. - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { //AppKey:注册的AppKey,详细见下面注释. //apnsCertName:推送证书名(不需要加后

Android 环信的使用

1.导入包 http://docs.easemob.com/doku.php?id=start:200androidcleintintegration:10androidsdkimport 在清单文件AndroidManifest.xml里加入以下权限,以及写上你注册的appkey 1.权限配置: <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://

环信 集成 笔记

环信的教程: 没有初始化SDK 去AppDelegate里面初始化 密码 User not exist         ?????????? 每一个应用都有自己的注册用户  去你的后台管理   去看你的注册的用户数 为什么demo的可以跑起来???????? 是在它的应用下注册的 怎么去注册用户  -注册用户 用户名字可以相同   不同的应用 那个打印的loginInfo 是这个字典的也就是用户的登录信息 你会发现打印的loginInfo上面还有一坨恶心的东西,那个是环信SDK自己打印的日志信息

iOS: 环信的推送

原文:http://m.blog.csdn.net/article/details?id=38824551 1.先创建一个apns证书,链接如下 http://developer.easemob.com/docs/emchat/ios/push/certificate.html 创建完证书后,将证书弄成p12文件,然后上传到环信后台 2.再创建真机调试证书,和描述文件,保证能进行真机调试.并且appid要又推送功能 3.绑定环信证书和appkey //注册 APNS文件的名字, 需要与后台上传证

iOS 环信集成问题(连文档都不说明的坑。。)

首先,关于环信SDK的下载和一些依赖库的添加,在此我就不做详细介绍,(http://www.easemob.com/download/im)附上环信官网文档,可以看一下,上面都可以下载,也有相关配置介绍. 今天主要说一下,环信集成遇到的各种坑,各种问题,有的连文档都不说明的坑..(主要是讲解完全集成环信,UI的聊天界面,单聊功能也是环信的这种情况) 各位可能刚在官网下载下来ChatDemo-UI3.0这个版本,会发现HyphenateFullSDK和官网文档有个不一样的地方,少了个文件(libH

微信公众号教程(11)公众账号接收非文字消息

公众账号接收非文字消息 在微信公众平台上用户都是用使用文字在进行交互的,但是有时候使用图片.语音.视频以及地理位置等可以实现一些非常棒的功能,比如"语音提醒"公众号里的发送语音就可以实现定时的事件提醒功能:比如ZTalk曾经搞过微信拍照晒电脑桌面的活动(响应的人太少,桑心--):比如一些预定本地化服务的公众号里发送当前地理位置就可以查询周边商家. 要实现这些功能首先得学会接收这些消息类型,比文字消息类型肯定要复杂很多了,目前我们能够接收的消息类型只有图片.地理位置以及退订消息,其他的如

iOS环信

工作近一个月,初出茅庐的我在这里写写这近一个月在编程遇到的问题,希望能帮到大家,如果有不对的地方也请大家帮忙指正,谢谢! 这次主要介绍一下环信,之前没有接触过,当分到这个任务的时候我并没有怂,如果认怂我想这一辈子也没法成功,既然老大相信我,我也要做出个样子来. 废话不过说,开始进入主题,首先遇到一个第三方的东西,第一反应就是下demo看文档http://docs.easemob.com/docs.php,demo对于第一次接触的人来说可能会看的很费劲,我建议先看文档,文档里的一些基础使用介绍的已

菜鸟搞环信

刚完成了环信的相关工作,刚好有时间来写一下关于环信的东西 马上进入主题吧 1.关于如何集成环信. 集成环信的话就不多说了 2.如何修改环信的昵称和头像. 这个我认为是重点.我也是一个新手,都是一步一个脚印,慢慢踩踏过来的. 我的做法是分两个,一个是利用环信的ext扩展作为突破口.第二个是利用本地缓存作为突破口. 首先说一下,为什么有两个? 因为,我们在发消息的时候,可以利用环信的ext扩展,把头像之类的东西,存到消息里面.这样,我们在发消息的时候就可以获得头像之类的东西,然后就可以更新chatv