API Reference
中文

WeChat

WeChat mini program provides two integration methods: plug-in docking and SDK docking. Please select the appropriate docking method according to the comparison below

Comparison between plug-in and SDK:

  1. Plug-in code does not directly provide SDK source code, does not occupy a mini program volume
  2. After the new version of the plug-in is released, the manager of the mini program will receive the update notification and can experience the new version of the plug-in and update the mini program. The mini-program release does not need to be reviewed again
  3. Mini program can call plug-ins, and plug-ins can no longer call other plug-ins
  4. In common subcontracting, plug-ins can only be used in one subcontracting, and the same plug-in cannot be referenced by multiple subcontractors at the same time. Plug-ins cannot be used in independent subcontracting for the time being

Plug-in version

1.1 Mini program management background add plug-in
  1. Log in to the WeChat public platform and click the Settings menu on the lower left
  2. Go to the Settings page and click the third-party Settings TAB
  3. In the plug-in management module, click the Add Plug-in button
  4. Search for wxfp, select the plug-in, and finish adding (After the application, the administrator will receive the application the next day. If the application is urgent, the administrator can contact the developer for quick approval)
1.2 Integrate mini program code

1.app.json declares the plugin

{


  "plugins": {
    "tdfp-plugin": {
      "version": "1.8.3",
      "provider": "wxc3b909c3d24c5417"
    }
  },


}
  • Note: The tripartite framework can be added accordingly. For example, in uni-app, you can add the above declaration to the mp-weixin module of the manifest.json file
  1. Initialize the plug-in js and necessary configuration
    In app.js, partnerCode is the required parameter, appname and channel are optional fields:
const plugin = requirePlugin('tdfp-plugin')
App({
  ......
  globalData: {
    ......
    _fmOpt: {
      partnerCode: "", // Please fill in your partner code
      appName: "", // Please fill in your app name,Please fill in different appnames for different applets of the same company
      channel:"", // Please fill in your channel
      env: "PRODUCTION" 
    }
  },
  onLaunch(){
    let fmagent = new plugin.FMAgent(this.globalData._fmOpt)
    fmagent.init()
  }
  ......
})
  1. Get BlackBox
    Our device fingerprint SDK adopts a call mode similar to WeChat API and supports passing success, fail, complete callback, and other configuration fields:
const plugin = requirePlugin('tdfp-plugin')
var that = this
var fmagent = new plugin.FMAgent(app.globalData._fmOpt)
fmagent.getInfo({
  page: that,  // The Page or Component object where FMAgent resides
  mode:'plugin',
  openid: '', // If openid or unionid is empty or undefined, do not encrypt upload, pass an empty string
  // If you have the unionid function enabled, pass in the encrypted user unionid
  // Please pass in the encrypted openid of the user (ensure that the encrypted openid is one-to-one corresponding to the original openid).
  unionid: '', 
  success: function (res) {},//Successful callback, res is BlackBox string
  fail: function (res) {},// Failure callback, res for various exception objects
  complete: function (res) {} //Complete callback, res for BlackBox string or various exception objects
})

2. SDK Mode

2.1 Adding a Domain Name

In Settings - development Settings - server domain request legal domain add:

EnvironmentDomain name
Domestic production(required)https://fp.tongdun.net

Note:

  • If the online version applet will only access the same production environment, add the first production domain name

2.3 Insert canvas node

Import in the corresponding wxml file that needs to call the sdk

<view>
    <canvas canvas-id='tdcanvas' style="visibility: hidden;position: fixed;z-index: -999;left: 9999px;"></canvas>
</view>

Note: You are advised to introduce it as a component

2.4 Initialization

Introduce the SDK on every page that needs to retrieve device information. For example, in the file pages/index/index.js:

import FMAgent from '../../fmsdk/fm-xxx-es.min.js'

Configuration
In the globalData of the app object in the app.js file

App({
	......
	globalData: {
		......
		_fmOpt: {
			partnerCode: "", // Please fill in your partner code
			appName: "", // Please fill in your app name
			env: "PRODUCTION" 
		 }
	}
})

2.5 Get the blackBox

Our device fingerprint SDK adopts a call mode similar to WeChat API and supports passing success, fail, complete callback and other configuration fields:

var that = this
var fmagent = new FMAgent(app.globalData._fmOpt)
fmagent.getInfo({
    page: that, // The Page or Component object where FMAgent resides
    openid: '', // user openid
    unionid: '', // If you have the unionid function enabled, pass in user unionid
    success: function (res) {
    // Successful callback, the res is blackBox string
    },
    fail: function (res) {
    // Failure callback, res for various exception objects
    },
    complete: function (res) {
    // Complete callback, res for BlackBox string or various exception objects
    }
})

The process of obtaining the blackbox will verify the necessary parameters such as the partnerCode, and the output log will be obtained if it is successful:

FMAgent: init succeeded.

Parameter Description

parametertypedescribesampleRequiredRemove Field
pageObjectThe page object or a component object that you are currently inthatYes
openidStringUser openid after encryption (encryption algorithm can be selected at will, please ensure one-to-one correspondence before and after encryption, MD5 or SHA256 is recommended) (remember that custom default value cannot be passed, no value please pass an empty string, otherwise collision will occur)ef54040ea9cb599823077Yes
modeStringdocking mode(Please pass in' plugin' for plug-in access, and ignore the sdk mode)'plugin'No
unionidStringUser unionid after encryption (encryption algorithm can be selected at will, please ensure one-to-one correspondence before and after encryption, MD5 or SHA256 is recommended) (remember that custom default value cannot be passed, no value please pass an empty string, otherwise collision will occur))ef54040ea9cb599823077No
timeoutNumberGet BlackBox timeout (default: 2500, including the total duration of collecting and sending requests, range: 2500-16000,Unit: ms)6000No
getInfoTypestringGet blackbox mode ('1' : use cached blackbox first, '2' : use real-time collection blackbox first, '3' : use unexpired blackbox first to expire, default mode is '1')'1'
getLocationAllowedBooleanWhether to collect location information. If you need to collect location information, please contact the operation to obtain privacy compliance guidance (The default is false. If you need to collect, please obtain the authorization of wechat and mini program location information in advance and set the current item to true).falseNolatitude、longitude
noClipboardBooleanWhether not to collect the clipboard (some phones will have the system prompt that the clipboard has been collected, and the clipboard can partially enhance our recovery ability) The default is truefalseNolipboard
successFunctionSuccessful callbackfunction(res) {/res for BlackBox string /}Yes
failFunctionFailed callbackfunction(res) {/res for various exception objects /}No
completeFunctionComplete callbackfunction(res) {/res for BlackBox string or various exception objects /}No

Note:

  • blackbox has an expiration date, so please do not cache blackbox yourself, there is a caching mechanism inside our SDK, so please call the getInfo interface where you need blackbox
  • Degrade The blackbox length ranges from 3000 to 5000 bytes. You are advised to report the blackbox to the body