2.0.6 • Published 8 years ago

secken-api v2.0.6

Weekly downloads
4
License
ISC
Repository
github
Last release
8 years ago

Secken SDK for Javascript

NPM version Build Status Downloads

Install

npm install secken-api

Usage

require && config

var Secken = require("secken-api");

var sk = new Secken({
    app_id: "",
    app_key: "",
    auth_id: ""
});

After initialization, Secken-api can help you to develop you project. Most of Secken-api's functions will return a promise object which using q, then you can use the primose object embed into you project.

Get Bind Qrcode Image Url

sk.getBind({
    auth_type: 2,
    callback: "http://www.callback/path"
})
.then(function(result) {
    // Success
    var qrcodeURL = result.qrcode_url;
    console.log("this is qrcode:", qrcodeURL);
    // do some things

    return sk.getResult(result.event_id);
}, function(result) {
    // Failed
    var errorCode = result.status;

    // do some things

    return sk.breakQ();
}).then(success, failed, notify);

Get Auth Qrcode Image Url

sk.getAuth({
    auth_type: 3,
    callback: "http://www.callback/path"
})
.then(function(result) {
    // Success
    var qrcodeURL = result.qrcode_url;
    console.log("this is qrcode:", qrcodeURL);
    // do some things

    return sk.getResult(result.event_id);
}, function(result) {
    // Failed
    var errorCode = result.status;

    // do some things

    return sk.breakQ();
}).then(success, failed, notify);

Realtime Auth

sk.realtimeAuth({
    action_type: 1,
    uid: " user id ",
}).then(function(data) {
    // Success

    // do some things

    return sk.getResult(data.event_id);
}, function(data) {
    return sk.breakQ();
}).then(success, failed, notify);

Get Result

sk.getResult(event_id, time)
.then(function(data) {
    // Success
    console.log(data);

    // do some things
}, function(data) {
    // Failed

});

This function will repeat getting result, the default delay time is 1000 ms, you can use parameter time to set the delay time, and you can use the primose's notify function to get each response. If you pass false as the value of time, it will run only once.

Offline Auth

sk.offlineAuth({
    dynamic_code: " code ",
    uid: " user id ",
}).then(function(data) {
    // Success

    // do some things

}, function(data) {});

Get Auth Page Url

var url = sk.authPage( " callback url " );

Get Signature

getSignature(params [,ignore]), pass an object type value for params and an array type value for ignore. You can use this function to get the signature string of a params object.

var signature = sk.getSignature(params, ['user_ip', 'username']);

Change log

2.0.4

  • use ES6
  • change init params' key
  • add request() function
  • update request to 2.67.0

Secken Team

Secken

2.0.6

8 years ago

2.0.5

8 years ago

2.0.4

8 years ago

2.0.3

9 years ago

2.0.2

9 years ago

2.0.1

9 years ago

2.0.0

9 years ago

0.1.7

9 years ago

0.1.6

9 years ago

0.1.5

9 years ago

0.1.4

9 years ago

0.1.3

9 years ago

0.1.2

9 years ago

0.1.1

9 years ago

0.1.0

9 years ago