0.0.3 • Published 4 years ago

real-name-auth v0.0.3

Weekly downloads
-
License
-
Repository
-
Last release
4 years ago

中宣部实名认证系统相关接口封装

  • 官方给的接口测试总共有八个,分别对应:认证成功、认证中、认证失败、查询认证成功、查询认证中、查询认证失败、游客用户行为上报、认证用户行为上报

大家在测试的时候注意区分哦,不然会一直测试中...

每个接口的测试码也是不同的 自行替换

注:setXxxUrl在测试环境下需要调用以切换到自己的测试地址,库内部默认值是线上环境的地址

import {RealNameAuth} from "real-name-auth";

// 以下三个参数由中宣部网络游戏实名认证系统提供
const appId = 'xxx';
const bizId = 'xxx';
const key = 'xxx';

//首先设置系统参数
RealNameAuth.init(appId, bizId, key);

// 实名认证接口调用示例——认证成功
RealNameAuth.setCheckUrl('https://wlc.nppa.gov.cn/test/authentication/check/测试码');
RealNameAuth.check('100000000000000006', '某一六', '110000190101020015')
    .then(r => {
        console.log('认证成功示例调用结果:', r)
    })
    .catch(e => {
        console.error('认证成功示例调用结果:', e)
    })

// 实名认证接口调用示例——认证中
RealNameAuth.setCheckUrl('https://wlc.nppa.gov.cn/test/authentication/check/测试码');
RealNameAuth.check('200000000000000001', '某二一', '110000190201010009')
    .then(r => {
        console.log('认证中示例调用结果:', r)
    })
    .catch(e => {
        console.error('认证中示例调用结果:', e)
    })

// 实名认证接口调用示例——认证失败
RealNameAuth.setCheckUrl('https://wlc.nppa.gov.cn/test/authentication/check/测试码');
RealNameAuth.check('200000000000008881', '某二一', '110000190201010009')
    .then(r => {
        console.log('认证失败示例调用结果:', r)
    })
    .catch(e => {
        console.error('认证失败示例调用结果:', e)
    })

// 实证查询接口调用示例——认证成功
RealNameAuth.setCheckUrl('https://wlc.nppa.gov.cn/test/authentication/query/测试码');
RealNameAuth.query('100000000000000001')
    .then(r => {
        console.log('查询示例-认证成功调用结果:', r)
    })
    .catch(e => {
        console.error('查询示例-认证成功调用结果:', e)
    })

// 实证查询接口调用示例——认证中
RealNameAuth.setCheckUrl('https://wlc.nppa.gov.cn/test/authentication/query/测试码');
RealNameAuth.query('200000000000000001')
    .then(r => {
        console.log('查询示例-认证中调用结果:', r)
    })
    .catch(e => {
        console.error('查询示例-认证中调用结果:', e)
    })

// 实证查询接口调用示例——认证失败
RealNameAuth.setCheckUrl('https://wlc.nppa.gov.cn/test/authentication/query/测试码');
RealNameAuth.query('300000000000000001')
    .then(r => {
        console.log('查询示例-认证失败调用结果:', r)
    })
    .catch(e => {
        console.error('查询示例-认证失败调用结果:', e)
    })


// 游戏用户行为数据上报调用示例——游客用户
RealNameAuth.setCheckUrl('https://wlc.nppa.gov.cn/test/collection/loginout/测试码');
RealNameAuth.update([
        //上线行为
        {
            no: 1,
            si: RealNameAuth.createSessionId(),
            bt: 0,
            ot: Math.floor(Date.now() / 1000),
            ct: 0,
            di: RealNameAuth.createSessionId()
        },
        //下线行为
        {
            no: 2,
            si: RealNameAuth.createSessionId(),
            bt: 1,
            ot: Math.floor(Date.now() / 1000),
            ct: 0,
            di: RealNameAuth.createSessionId()
        }
    ])
    .then(r => {
        console.log(r)
    })
    .catch(e => {
        console.error(e)
    })

// 游戏用户行为数据上报调用示例——认证用户
RealNameAuth.setCheckUrl('https://wlc.nppa.gov.cn/test/collection/loginout/测试码');
RealNameAuth.update([
        //上线行为
        {
            no: 1,
            si: RealNameAuth.createSessionId(),
            bt: 0,
            ot: Math.floor(Date.now() / 1000),
            ct: 0,
            pi: '1fffbjzos82bs9cnyj1dna7d6d29zg4esnh99u'
        },
        //下线行为
        {
            no: 2,
            si: RealNameAuth.createSessionId(),
            bt: 1,
            ot: Math.floor(Date.now() / 1000),
            ct: 0,
            pi: '1fffbkmd9ebtwi7u7f4oswm9li6twjydqs7qjv'
        }
    ])
    .then(r => {
        console.log(r)
    })
    .catch(e => {
        console.error(e)
    })
0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago