|
[开发工具]
apicloud如何引入融云的token
[复制链接]
var chatID = api.pageParam.customerchat;
var url="";
var method="POST";
var common_url = 'https://**.**.rong.io/user/getToken.json';
var appId = 'A6055656158945';//应用程序的id
var key = '24CC6640-7AB3-9EBD-5CAA-F968FD13F893';//应用程序的key
var now = parseInt(Date.now()/1000);
var rand=Math.ceil(Math.random()*10000000);
var aKey="p5tvi9dspmys4"; //融云注册申请
var sKey="tax3FzCQFmP";//融云注册申请
var appKey = SHA1(sKey + "" + rand + "" + now) ;
api.ajax({
url: 'https://**.**.rong.io/user/getToken.json' ,
method: method,
cache: false,
timeout: 2000,
headers: {
"Content-type": "application/json",
"App-Key":aKey,
"Nonce":rand,
"Timestamp":now,
"Signature":appKey
},
data: {body:"userId="+chatID+"&name="+chatID}//荣誉上注册的用户id和用户名,头像可以无
}, function (ret, err) {
Token =ret.token;
alert(JSON.stringify(Token));//返回获得的Token
});
|
|