• API
  • 请求示例
  • 按键精灵
  • 按键精灵2014
  • 懒人精灵
  • EasyClick
  • Python
  • Java
Import "Cjson.lua"
Import "ShanHai.lua"

Thread.SetShareVar "请求地址", "https://api.yankami.cn/"

Thread.SetShareVar "项目ID", ""

Thread.SetShareVar "项目秘钥", ""

Thread.SetShareVar "卡密", ""

Thread.SetShareVar "设备编号", GetDeviceID()

换绑机器码()

Function 换绑机器码()
    Dim timeStamp = Time()
    Dim sign = Encode.Md5(Thread.GetShareVar("项目ID")&Thread.GetShareVar("项目秘钥")&timeStamp)
    Dim 请求返回 = URL.Get(Thread.GetShareVar("请求地址")&"jqm?xmid="&Thread.GetShareVar("项目ID")&"&km="&Thread.GetShareVar("卡密")&"&jqm="&Thread.GetShareVar("设备编号")&"&timeStamp="&timeStamp&"&sign="&sign,5)
    TracePrint "换绑机器码:"&请求返回
    Dim jqmResponse
    If InStr(1, 请求返回, "code") <> 0 Then
        jqmResponse = Cjson.Decode(请求返回)
    End If
    If jqmResponse And jqmResponse["code"] = 200 Then
        TracePrint "换绑成功"
        Dialog.MsgBox("\t\t\t\t\t\t\t\t  提示:换绑成功!",0)
    Else
        TracePrint "换绑失败"
        Dialog.MsgBox("\t\t\t\t\t\t\t\t  提示:换绑失败!",0)
    End If
    EndScript//停止辅助
End Function    
Dim 项目ID,项目秘钥,卡密,设备编号

项目ID = ""

项目秘钥 = ""

卡密 = ""

设备编号 = CStr(Plugin.Sys.GetHDDSN())

Call 换绑机器码()

Function 换绑机器码()
    Dim timeStamp,sign,请求地址,请求URL,响应内容,状态
    timeStamp = getTime()
    sign = Plugin.Encrypt.Md5String(项目ID&项目秘钥&timeStamp)
    请求地址 = "http://api.yankami.cn/jqm"
    请求URL = 请求地址&"?xmid="&项目ID&"&km="&卡密&"&jqm="&设备编号&"&timeStamp="&timeStamp&"&sign="&sign
    TracePrint "换绑机器码 URL:"&请求URL
    响应内容 = Lib.网络.获得网页源文件_增强版(请求URL,"utf-8")
    TracePrint "响应内容:"&响应内容
    If InStr(1, 响应内容, "{") <> 1 or InStr(1, 响应内容, "code") = 0 Then
        TracePrint "提示:换绑失败!"
        MessageBox "提示:换绑失败!"
        ExitScript//停止辅助
    Else
        状态 = json解析(响应内容, "code")
        TracePrint "状态:"&状态
        If 状态 <> 200 Then
            TracePrint "提示:换绑失败!"
            MessageBox "提示:换绑失败!"
        Else
            TracePrint "提示:换绑成功!"
            MessageBox "提示:换绑成功!"
        End If
        ExitScript//停止辅助
    End If
End Function

Function json解析(resp,json路径)
    Set sc = CreateObject("MSScriptControl.ScriptControl")
    sc.Language = "JScript"
    sc.AddCode "var tmp = " & resp & ";"
    json解析 = sc.Eval("tmp." & json路径)
End Function

Function getTime()
    Dim 年, 月, 天, 小时, 分钟, 秒, dataTime
    dataTime = Plugin.GetSysInfo.GetDateTime()
    年 = Year(dataTime)
    月 = Month(dataTime) - 2
    天 = Day(dataTime) - 1
    小时 = Hour(dataTime)
    分钟 = Minute(dataTime)
    秒 = Second(dataTime)
    If 月 < 0 Then
        月 = 月 + 12
        年 = 年 - 1
    End If
    getTime = (((((Round((年 - 1) * 365 + 年 / 4 - 年 / 100 + 年 / 400) + Int((((367 * 月) / 12) - 30) + 59) + 天 - 719162) * 24 + (小时 - 8)) * 60) + 分钟) * 60 + 秒)
End Function    
local 请求地址 = "https://api.yankami.cn/"
local 项目ID = ""
local 项目秘钥 = ""

local 卡密 = ""

local 设备编号 = "LanRen" .. os.time()

function 换绑机器码()
	local timeStamp = os.time()
	local sign = MD5(项目ID .. 项目秘钥 .. timeStamp);
	local ret, code = httpPost(请求地址 .. "jqm", "xmid=" .. 项目ID .. "&km=" .. 卡密 .. "&jqm=" .. 设备编号 .. "&timeStamp=" .. timeStamp .. "&sign=" .. sign)
	print("换绑机器码:" .. ret)
	if code == 200 and isJsonStr(ret) then
		ret = jsonLib.decode(ret)
	end
	if code ~= 200 or ret.code ~= 200 then
		print("换绑失败,请重试!")
		toast("换绑失败,请重试!")
	else
		print("换绑成功,请重新运行!")
		toast("换绑成功,请重新运行!")
	end
end

换绑机器码()    
var 请求地址 = "https://api.yankami.cn/"

var 项目ID = ""

var 项目秘钥 = ""

var 卡密 = ""

var 设备编号 = DeviceWrapper.prototype.getAndroidId()

换绑机器码()

function 换绑机器码() {
    var timeStamp = parseInt(new Date().getTime() / 1000)
    console.log("timeStamp:" + timeStamp)
    var sign = UtilsWrapper.prototype.dataMd5(项目ID + 项目秘钥 + timeStamp)
    请求返回 = sendGet(请求地址 + "jqm?xmid=" + 项目ID + "&km=" + 卡密 + "&jqm=" + 设备编号 + "&timeStamp=" + timeStamp + "&sign=" + sign)
    console.log("换绑机器码:" + 请求返回)
    if (!请求返回.startsWith("{") || !请求返回.endsWith("}")) {
        console.log("换绑失败!")
        toast("换绑失败!")
    } else {
        var json = JSON.parse(请求返回)
        if (json["code"] != 200) {
            toast("换绑失败!")
        } else {
            toast("换绑成功!")
        }
    }
}    
import json
import requests
import hashlib
import time
import datetime


def 换绑机器码(项目ID, 项目秘钥, 卡密, 机器码):
    timeStamp = int(time.time())
    print(f"时间戳: {timeStamp}")
    sign = hashlib.md5((str(项目ID) + 项目秘钥 + str(timeStamp)).encode('utf-8')).hexdigest()
    params = {"xmid": 项目ID, "km": 卡密, "jqm": 机器码, "timeStamp": timeStamp, "sign": sign}
    try:
        if False:
            result = requests.get('https://api.yankami.cn/jqm', params=params).json()
        else:
            result = requests.post('https://api.yankami.cn/jqm', data=params).json()
        print("result:", result)
        code = result["code"]
        if code != 200:
            print("换绑机器码 失败!")
        else:
            print("换绑机器码 成功!")

    except Exception as e:
        print(f"换绑机器码 失败:{e}")


if __name__ == "__main__":
    项目ID = ""
    项目秘钥 = ""
    卡密 = ""
    机器码 = str(int(time.time()))
    换绑机器码(项目ID, 项目秘钥, 卡密, 机器码)
    

pom


    
    

java

package com.xxx.crm.controller.长情云验证;

import org.json.JSONException;
import org.json.JSONObject;

import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class 换绑机器码 {
	
	public static void main(String[] args) throws Exception {
		String xmid = "";
		String km = "";
		String xmmy = "";
		String jqm = String.valueOf(System.nanoTime());
		long timeStamp = System.currentTimeMillis() / 1000;
		String sign = getMD5(xmid + xmmy + timeStamp);
		String url = "https://api.yankami.cn/jqm?"
					 + "xmid=" + xmid
					 + "&km=" + km
					 + "&jqm=" + jqm
					 + "&timeStamp=" + timeStamp
					 + "&sign=" + sign;
		JSONObject jsonEntity = getRequest(url);
		System.out.println("jsonEntity:" + jsonEntity);
		if (jsonEntity != null) {
			int code = jsonEntity.getInt("code");
			if (code == 200) {
				System.out.println("换绑成功!");
			} else {
				System.out.println("换绑失败!");
			}
		}
	}
	
	public static String getMD5(String text) throws NoSuchAlgorithmException {
		byte[] bytes = MessageDigest.getInstance("MD5").digest(text.getBytes(StandardCharsets.UTF_8));
		StringBuilder builder = new StringBuilder(32);
		for (byte b : bytes) {
			builder.append(String.format("%02x", b));
		}
		return builder.toString();
	}
	
	public static JSONObject getRequest(String url) throws Exception {
		URL obj = new URL(url);
		HttpURLConnection con = (HttpURLConnection) obj.openConnection();
		con.setConnectTimeout(10000);
		con.setRequestMethod("GET");
		if (con.getResponseCode() == 200) {
			return getJSON(responseReader(con.getInputStream()));
		}
		return null;
	}
	
	private static String responseReader(InputStream inputStream) throws IOException {
		InputStreamReader inputStreamReader = new InputStreamReader(inputStream, StandardCharsets.UTF_8);
		StringBuilder stringBuilder = new StringBuilder();
		int len;
		char[] chars = new char[8192];
		while ((len = inputStreamReader.read(chars)) != -1) {
			stringBuilder.append(chars, 0, len);
		}
		inputStreamReader.close();
		return stringBuilder.toString();
	}
	
	private static JSONObject getJSON(String text) throws JSONException {
		if (text != null) {
			int indexOf = text.indexOf("{");
			int lastIndexOf = text.lastIndexOf("}");
			if (indexOf != -1 && lastIndexOf != -1) {
				return new JSONObject(text.substring(indexOf, lastIndexOf + 1));
			}
		}
		return null;
	}
}
    
换绑机器码(JSON)
请求支持GET和POST:https://api.yankami.cn/jqm
请求参数 是否必须 说明
xmid 是 项目ID
km 是 卡密
谁开卡填谁的卡密 用户输入
jqm 是 机器码 新设备的唯一标识
timeStamp 是 10位 时间戳
sign 是 签名 md5(项目ID + 项目秘钥 + 时间戳)
响应参数 响应状态 说明
code 200 成功
code 400 参数错误
code 500 更换机器码失败
响应信息 响应参数 说明
message ... 响应 code 是 400 时返回