YouzanYun SDK for Node.
npm i youzanyun-sdk --save
可参考 examples
const youzanyun = require('youzanyun-sdk');
// 获取token
const resp = youzanyun.token.get({
authorize_type: 'authorization_code',
client_id: 'YOUR_CLIENT_ID',
client_secret: 'YOUR_CLIENT_SECRET',
code: 'YOUR_CODE',
redirect_uri: 'YOUR_REDIRECT_URI',
});
const youzanyun = require('youzanyun-sdk');
const resp = youzanyun.token.get({
authorize_type: 'silent',
client_id: 'YOUR_CLIENT_ID',
client_secret: 'YOUR_CLIENT_SECRET',
grant_id: 110,
refresh: true, // 是否获取refresh_token(可通过refresh_token刷新token)
});
const youzanyun = require('youzanyun-sdk');
// 刷新token
const resp = youzanyun.token.get({
authorize_type: 'refresh_token',
client_id: 'YOUR_CLIENT_ID',
client_secret: 'YOUR_CLIENT_SECRET',
refresh_token: 'YOUR_REFRESH_TOKEN',
});
const youzanyun = require('youzanyun-sdk');
const token = 'f59b1a6bb04f4eqweqd1c6af315d';
const params = {tid: 'E20190509110527067500013'};
const resp = youzanyun.client.call({
api: 'youzan.trade.get',
version: '4.0.0',
token,
params,
});
const youzanyun = require('youzanyun-sdk');
const token = 'f59b1a6bb0asdasq613d1c6af315d';
const files = {'image': path.resolve(__dirname, './pic.png')};
const resp = youzanyun.client.call({
api: 'youzan.materials.storage.platform.img.upload',
version: '3.0.0',
token,
params: {},
files,
});
const youzanyun = require('youzanyun-sdk');
const messages = 'YOUR_RECEIVED_MESSAGES';
const clientSecret = 'YOUR_CLIENT_SECRET';
const resp = youzanyun.crypto.decrypt(messages, clientSecret);