|
本帖最后由 zwfgdlc 于 2017-3-24 14:59 编辑
仓促而作,还很粗糙.
调用方法,请参照示例代码,很简单.
- #pragma once
- #include <stdio.h>
- #include <tchar.h>
- #include <Windows.h>
- #define API_GET_USER_LIST 1
- #define API_KICK_USER 3
- #define API_GET_ONLINE_USER 4
- #define API_ADD_USER 5
- #define API_MODIFY_USER_INFO 6
- #define API_ENABLE_DISABLE_USER 7
- #define API_DELETE_USER 8
- #define API_GET_ROUTER_BASEINFO 9
- #define API_WHITELIST_SET 10
- #define API_QUERY_USER_INFO 11
- enum WHITETYPE{
- MAC = 0,
- HTTP,
- IP,
- HTTPS
- };
- int __stdcall public_encrypt(unsigned char* data, int data_len, unsigned char* key, unsigned char* encrypted);
- void __stdcall UrlEncode(LPCSTR lpszIn, LPSTR lpszOut, DWORD Len);
- BOOL __stdcall Base64(LPSTR lpszData, DWORD DataLen, LPSTR lpszBase64, LPDWORD dwBase64Len);
- BOOL __stdcall EnvInitialize(LPSTR lpOpenId, LPSTR lpDevice, LPSTR lpPublicKey);
- int __stdcall GetDeviceList(LPSTR lpszBuffer, DWORD dwBufferLen);
- int __stdcall GetUserList(LPSTR lpszBuffer, DWORD dwBufferLen);
- int __stdcall GetOnlineUserList(LPSTR lpszBuffer, DWORD dwBufferLen, int Limit, int Skip);
- int __stdcall KickUser(LPSTR lpszBuffer, DWORD dwBufferLen, LPCSTR lpszMac);
- int __stdcall AddUser(LPSTR lpszBuffer, DWORD dwBufferLen, LPCSTR lpszUserName, LPCSTR lpszPassword, int Upload = 0, int Download = 0, LPCSTR State = "up", LPCSTR Comment = "", LPCSTR Date = "", LPCSTR Ppptype = "web", int Share = 1, int AutoMac = 0, LPCSTR IpAddr = "", LPCSTR Mac = "", LPCSTR Address = "", LPCSTR Name = "", LPCSTR Phone = "", LPSTR StartDate = "", LPCSTR Cardid = "", int Packages = 0, int Money = 0);
- int __stdcall ModifyUserInfo(LPSTR lpszBuffer, DWORD dwBufferLen, int id, LPSTR State = "up", LPSTR Comment = "", LPSTR lpszUserName = "", LPSTR lpszPassword = "", LPSTR Date = "", LPSTR Ppptype = "web", int Share = 1, int AutoMac = 0, int UpLoad = 0, int DownLoad = 0, LPSTR IpAddr = "", LPSTR Mac = "", LPSTR Address = "", LPSTR Name = "", LPSTR Phone = "", LPSTR StartDate = "", LPSTR Cardid = "", int Packages = 0, int Money = 0);
- int __stdcall EnableUser(LPSTR lpszBuffer, DWORD dwBufferLen, LPCSTR lpszId, BOOL bState = TRUE);
- int __stdcall GetUserId(LPCSTR lpszUserName, LPSTR lpszId);
- int __stdcall DeleteUser(LPSTR lpszBuffer, DWORD dwBufferLen, LPCSTR lpszId);
- int __stdcall GetRouterInfo(LPSTR lpszBuffer, DWORD dwBufferLen);
- int __stdcall SetWhiteList(LPSTR lpszBuffer, DWORD dwBufferLen, LPCSTR WhiteData, WHITETYPE Type);
- int __stdcall QueryUserInfo(LPSTR lpszBuffer, DWORD dwBufferLen, LPCSTR lpszUserName);
复制代码
示例:
- // iKuaiOpenTest.cpp : 定义控制台应用程序的入口点。
- //
- #include "stdafx.h"
- #include "../iKuaiOpen/lib.h"
- #pragma comment(lib, "../release/ikuaiopen.lib")
- //RSA公钥
- char* lpszPublicKey = "-----BEGIN PUBLIC KEY-----
- ";
- //开发者ID
- CHAR* lpszOpenId = "";
- //设备ID
- CHAR* lpszDevice = "";
- CHAR buffer[8192] = { 0 };
- int _tmain(int argc, _TCHAR* argv[])
- {
- //初始化环境,设置公钥,开发者ID,设备ID
- EnvInitialize(lpszOpenId, lpszDevice, lpszPublicKey);
- //获取账号列表
- GetUserList(buffer, sizeof(buffer));
- //获取在线用户列表
- GetOnlineUserList(buffer, sizeof(buffer), 100/*获取条数*/, 0/*跳过条数*/);
- //添加账号,设定用户名,密码即可,其他参数可以使用默认值
- AddUser(buffer, sizeof(buffer), "用户名", "密码");
- //查找用户ID
- CHAR szId[8] = { 0 };
- GetUserId("用户名", szId);
- //启用/禁用账号,
- EnableUser(buffer, sizeof(buffer), "用户ID", FALSE/*TRUE为启用,FALSE为禁用*/);
- //删除账号
- DeleteUser(buffer, sizeof(buffer), szId);
- //获取路由基本信息
- GetRouterInfo(buffer, sizeof(buffer));
- //查询账号信息
- QueryUserInfo(buffer, sizeof(buffer), "用户名");
- return 0;
- }
复制代码 2017/3/23更新,增加一个API测试工具
Release.rar
(666.41 KB, 下载次数: 65)
|
|