|
- var now = new Date();
- var number = now.getSeconds();
- //这将产生一个基于目前时间的0到59的整数。
- var timestamp = Date.parse(new Date());
- timestamp = timestamp / 1000;
- var AppKey = ""; //填写自己的参数
- var appSecret = ""; //填写自己的参数
- var Nonce = number;
- var Timestamp = timestamp;
- var Signature = SHA1(appSecret + Nonce + Timestamp);
- api.ajax({
- url: 'http://**.****.**/user/getToken.json',
- method: 'post',
- headers: {
- "Content-Type": "Application/x-www-form-urlencoded",
- "App-Key": AppKey,
- "Nonce": Nonce,
- "Timestamp": Timestamp,
- "Signature": Signature
- },
- data: {
- 'values': {
- userId: uid,
- name: uid,
- //portraitUri: "http://**.**1.z0.glb**.**/apicloud/9ddf7d56095abd26f2c7ef72bb142563.png"
- }
- }
- }, function (ret, err) {
- if (ret) {
- token = ret.token;
- } else {
- api.alert({
- msg: JSON.stringify(err)
- });
- }
- })
复制代码
|
|