### Install Go SDK with go get Source: https://docs.paojiaoyun.com/go_sdk.html Use `go get -u github.com/paojiaoyun/sdk-go` to fetch the latest version of the Paojiaoyun Go SDK. ```sh go get -u github.com/paojiaoyun/sdk-go ``` -------------------------------- ### PJYSDK card login example Source: https://docs.paojiaoyun.com/py_sdk.html Complete example showing initialization, setting device ID and card, performing card login, and handling heartbeat failures with re-login. Requires app_key and app_secret from the developer console. ```python from PJYSDK import * import os import time # 初始化 app_key 和 app_secret 在开发者后台新建软件获取 pjysdk = PJYSDK(app_key='AppKey', app_secret='AppSecret') pjysdk.debug = True # 心跳失败回调 def on_heartbeat_failed(hret): print(hret.message) if hret.code == 10214: os._exit(1) # 退出脚本 print("心跳失败,尝试重登...") login_ret = pjysdk.card_login() if login_ret.code == 0: print("重登成功") else: print(login_ret.message) # 重登失败 os._exit(1) # 退出脚本 if __name__ == '__main__': pjysdk.on_heartbeat_failed = on_heartbeat_failed # 设置心跳失败回调函数 pjysdk.set_device_id('123') # 设置设备唯一ID pjysdk.set_card('Card') # 设置卡密 ret = pjysdk.card_login() # 卡密登录 if ret.code != 0: # 登录失败 print(ret.message) os._exit(1) # 退出脚本 # 登录成功,后面写你的业务代码 while 1: # 测试用,hold住主线程不要退出,记得删除,后面应该是你的代码了 print(pjysdk.get_time_remaining()) time.sleep(5) ``` -------------------------------- ### Go SDK usage example Source: https://docs.paojiaoyun.com/go_sdk.html Complete example showing SDK initialization, setting device ID and card, card login, heartbeat failure callback, and retrieving remaining time. Requires AppKey and AppSecret from the Paojiaoyun developer console. The main loop holds the program to test login; remove it for production logic. ```go package main import ( "fmt" "os" "time" pjy "github.com/paojiaoyun/sdk-go" ) func main() { // 初始化sdk, appKey 和 appSecret 在泡椒云开发者后台获取 pjysdk := pjy.NewPJYSDK("AppKey", "AppSecret") pjysdk.SetDebug(true) // 心跳失败回调 pjysdk.OnHeartbeatFail(func(r *pjy.Resp[pjy.HeartbeatResult]) { fmt.Println(r.Message) if r.Code == 10214 { os.Exit(1) } fmt.Println("心跳失败,尝试重登...") loginRet, err := pjysdk.CardLogin() if err != nil { fmt.Println("重登失败:", err) os.Exit(1) } if loginRet.Code != 0 { fmt.Println(loginRet.Message) os.Exit(1) } fmt.Println("重登成功") }) pjysdk.SetDeviceID("123") // 设置设备唯一ID pjysdk.SetCard("Card") // 设置卡密 // 卡密登录 loginRet, err := pjysdk.CardLogin() if err != nil { fmt.Println("登录请求异常:", err) os.Exit(1) } if loginRet.Code != 0 { fmt.Println(loginRet.Message) os.Exit(1) } // 登录成功后测试用,hold住主线程不要退出,记得删除,后面应该是你的逻辑代码了 for { remaining := pjysdk.GetTimeRemaining() fmt.Println("剩余时间(秒):", remaining) time.Sleep(5 * time.Second) } } ``` -------------------------------- ### GET /v1/software/config Source: https://docs.paojiaoyun.com/software.html 获取软件配置。软件配置在开发者后台更改或设置。 ```APIDOC ## GET /v1/software/config ### Description 获取软件配置。软件配置在开发者后台更改或设置。 ### Method GET ### Endpoint http://api.paojiaoyun.com/v1/software/config ### Parameters #### Query Parameters - **app_key** (string) - Required - 软件的app_key - **nonce** (string) - Required - 不超过36位的随机字符串(建议用UUID) - **timestamp** (int64) - Required - 时间戳,秒级(10位数) - **sign** (string) - Required - 签名 ### Response #### Success Response (200) - **code** (int) - 返回码,0表示正确,详细参照返回码对照表 - **message** (string) - 请求出错时的错误信息 - **result** (object) - 请求正确时,若有额外数据要返回,则结果封装在该字段。若无额外数据,则无此字段。 - **config** (string) - 配置 #### Response Example { "code": 0, "message": "ok", "result": { "config": "config1|config2" } } ``` -------------------------------- ### go get -u github.com/paojiaoyun/sdk-go Source: https://docs.paojiaoyun.com/go_sdk.html 通过 go get 命令获取泡椒云 Go SDK。 ```APIDOC ## [GET] go get -u github.com/paojiaoyun/sdk-go ### Description 通过 go get 命令获取泡椒云 Go SDK。 ### Method GET ### Endpoint go get -u github.com/paojiaoyun/sdk-go ### Parameters 无 ### Request Example ```sh go get -u github.com/paojiaoyun/sdk-go ``` ### Response #### Success Response (200) 无 #### Response Example 无 ``` -------------------------------- ### Get user configuration with pjysdk.get_user_config() Source: https://docs.paojiaoyun.com/py_sdk.html Retrieves the user configuration. Takes no parameters and returns a dictionary; see the referenced interface response for an example. ```python ret = pjysdk.get_user_config() ``` -------------------------------- ### GET /v1/software/notice Source: https://docs.paojiaoyun.com/software.html 获取软件公告。 ```APIDOC ## GET /v1/software/notice ### Description 获取软件公告。 ### Method GET ### Endpoint http://api.paojiaoyun.com/v1/software/notice ### Parameters #### Query Parameters - **app_key** (string) - Required - 软件的app_key - **nonce** (string) - Required - 不超过36位的随机字符串(建议用UUID) - **timestamp** (int64) - Required - 时间戳,秒级(10位数) - **sign** (string) - Required - 签名 ### Response #### Success Response (200) - **code** (int) - 返回码,0表示正确,详细参照返回码对照表 - **message** (string) - 请求出错时的错误信息 - **result** (object) - 请求正确时,若有额外数据要返回,则结果封装在该字段。若无额外数据,则无此字段。 - **notice** (string) - 软件公告 #### Response Example { "code": 0, "message": "ok", "result": { "notice": "欢迎使用━(*`∀´*)ノ亻!" } } ``` -------------------------------- ### Get card configuration with pjysdk.get_card_config() Source: https://docs.paojiaoyun.com/py_sdk.html Retrieves the card configuration. Takes no parameters and returns a dictionary; see the referenced interface response for an example. ```python ret = pjysdk.get_card_config() ``` -------------------------------- ### GET /v1/card/config Source: https://docs.paojiaoyun.com/config.html 获取卡密配置。通过提供 app_key、card、nonce、timestamp 和 sign 参数,获取指定卡密的配置信息。 ```APIDOC ## GET /v1/card/config ### Description 获取卡密配置。 ### Method GET ### Endpoint http://api.paojiaoyun.com/v1/card/config ### Parameters #### Query Parameters - **app_key** (string) - Required - 软件的app_key - **card** (string) - Required - 登录的卡密 - **nonce** (string) - Required - 不超过36位的随机字符串(建议用UUID) - **timestamp** (int64) - Required - 时间戳,秒级(10位数) - **sign** (string) - Required - 签名 ### Response #### Success Response (200) - **code** (int) - 返回码,0表示正确,详细参照返回码对照表 - **message** (string) - 请求出错时的错误信息 - **result** (object) - 请求正确时,若有额外数据要返回,则结果封装在该字段。若无额外数据,则无此字段。 - **config** (string) - 卡密的配置 #### Response Example { "code": 0, "message": "ok", "result": { "config": "config1|config2" } } ``` -------------------------------- ### TrialLogin - Trial login Source: https://docs.paojiaoyun.com/go_sdk.html Performs a trial login. On success, automatically starts a heartbeat. Returns a response with a TrialLoginResult. ```go ret, err := pjysdk.TrialLogin() // (*pjy.Resp[pjy.TrialLoginResult], error) ``` -------------------------------- ### TrialLogin Syntax Source: https://docs.paojiaoyun.com/autojs_sdk.html Call pjysdk.TrialLogin() to perform a trial login. After successful login, a heartbeat thread is automatically started; use pjysdk.GetHeartbeatResult() to retrieve the heartbeat result. Returns an Object (see trial response example). ```javascript let ret = pjysdk.TrialLogin(); ``` -------------------------------- ### GET /v1/user/config Source: https://docs.paojiaoyun.com/config.html 获取用户配置。通过提供 app_key、nonce、timestamp、username 和 sign 参数,获取指定用户的配置信息。 ```APIDOC ## GET /v1/user/config ### Description 获取用户配置。 ### Method GET ### Endpoint http://api.paojiaoyun.com/v1/user/config ### Parameters #### Query Parameters - **app_key** (string) - Required - 软件的app_key - **nonce** (string) - Required - 不超过36位的随机字符串(建议用UUID) - **timestamp** (int64) - Required - 时间戳,秒级(10位数) - **username** (string) - Required - 用户名 - **sign** (string) - Required - 签名 ### Response #### Success Response (200) - **code** (int) - 返回码,0表示正确,详细参照返回码对照表 - **message** (string) - 请求出错时的错误信息 - **result** (object) - 请求正确时,若有额外数据要返回,则结果封装在该字段。若无额外数据,则无此字段。 - **config** (string) - 配置 #### Response Example { "code": 0, "message": "ok", "result": { "config": "config1|config2" } } ``` -------------------------------- ### Install PJYSDK via pip Source: https://docs.paojiaoyun.com/py_sdk.html Install or upgrade the PJYSDK package using pip. ```sh pip install --upgrade PJYSDK ``` -------------------------------- ### 获取软件配置: pjysdk.get_software_config() Source: https://docs.paojiaoyun.com/py_sdk.html Retrieves the software configuration. Takes no parameters. Returns a dictionary; see the referenced interface response for an example. ```python ret = pjysdk.get_software_config() ``` -------------------------------- ### TrialLogin Source: https://docs.paojiaoyun.com/go_sdk.html Performs a trial login. On success, a heartbeat is automatically started. ```APIDOC ## TrialLogin ### Description Performs a trial login. On success, a heartbeat is automatically started. ### Method Function call ### Signature `pjysdk.TrialLogin() (*pjy.Resp[pjy.TrialLoginResult], error)` ### Parameters None ### Return - **ret** (*pjy.Resp[pjy.TrialLoginResult]) - Response object containing trial login result. - **err** (error) - Error if any. ``` -------------------------------- ### GetSoftwareConfig syntax Source: https://docs.paojiaoyun.com/jsd_sdk.html Groovy syntax for pjysdk.GetSoftwareConfig(). Takes no parameters. Returns an Object; see the referenced interface response for an example. ```groovy ret = pjysdk.GetSoftwareConfig() ``` -------------------------------- ### GetUserConfig syntax Source: https://docs.paojiaoyun.com/ajjl_sdk.html Calls PJYSDK.GetUserConfig with no parameters to retrieve user configuration. Returns a Table, with an example response referenced externally. ```xojo ret = PJYSDK.GetUserConfig() ``` -------------------------------- ### Get user configuration: pjysdk.GetUserConfig() Source: https://docs.paojiaoyun.com/lr_sdk.html Retrieves the user configuration. Takes no parameters and returns a Table, as shown in the referenced interface response. ```lua local ret = pjysdk.GetUserConfig() ``` -------------------------------- ### pjysdk.TrialLogin() Source: https://docs.paojiaoyun.com/autojs_sdk.html Performs a trial login. After successful login, a thread is automatically started to send heartbeat packets. Developers can use pjysdk.GetHeartbeatResult() to check the heartbeat status. ```APIDOC ## pjysdk.TrialLogin() ### Description Performs a trial login. After successful login, a thread is automatically started to send heartbeat packets. Developers can use pjysdk.GetHeartbeatResult() to check the heartbeat status. ### Method TrialLogin ### Syntax ```js let ret = pjysdk.TrialLogin(); ``` ### Parameters None ### Return Value Object type, example: [参考接口返回](https://docs.paojiaoyun.com/trial.html#%E5%93%8D%E5%BA%94%E7%A4%BA%E4%BE%8B) ``` -------------------------------- ### Get card configuration: pjysdk.GetCardConfig() Source: https://docs.paojiaoyun.com/lr_sdk.html Retrieves the card configuration. Takes no parameters and returns a Table, as shown in the referenced interface response. ```lua local ret = pjysdk.GetCardConfig() ``` -------------------------------- ### UserLogin syntax Source: https://docs.paojiaoyun.com/autojs_sdk.html Syntax for pjysdk.UserLogin(). Must call pjysdk.SetUser(username, password) before invoking. Login starts a heartbeat thread automatically; use pjysdk.GetHeartbeatResult() to get the heartbeat result. Returns an Object (see linked response example). ```javascript let ret = pjysdk.UserLogin(); ``` -------------------------------- ### Initialize SDK with NewPJYSDK Source: https://docs.paojiaoyun.com/go_sdk.html Creates a new PJYSDK instance with appKey and appSecret. Both parameters are required strings obtained from the developer backend. ```go pjysdk := pjy.NewPJYSDK(appKey, appSecret string) ``` -------------------------------- ### 初始化 SDK: pjysdk.init(app_key, app_secret) Source: https://docs.paojiaoyun.com/lr_sdk.html 使用开发者后台获取的 app_key 和 app_secret 初始化 SDK。两个参数均为必传字符串。 ```lua pjysdk.init(app_key, app_secret) ``` -------------------------------- ### pjysdk.UserLogin() Source: https://docs.paojiaoyun.com/autojs_sdk.html Logs in a user. Requires prior initialization with pjysdk.SetUser(username, password). Automatically starts a heartbeat thread; use pjysdk.GetHeartbeatResult() to get heartbeat results. ```APIDOC ## pjysdk.UserLogin() ### Description Logs in a user. Requires prior initialization with pjysdk.SetUser(username, password). Automatically starts a heartbeat thread; use pjysdk.GetHeartbeatResult() to get heartbeat results. ### Syntax ```js let ret = pjysdk.UserLogin(); ``` ### Parameters None ### Return Value Object type, e.g., [参考接口返回](https://docs.paojiaoyun.com/user.html#%E5%93%8D%E5%BA%94%E7%A4%BA%E4%BE%8B-2) ``` -------------------------------- ### Get heartbeat result Source: https://docs.paojiaoyun.com/csharp_sdk.html Returns the heartbeat result. Code == 0 indicates normal heartbeat, -9 indicates verification not started, other codes have error message in Message. ```csharp PJYResult GetHeartbeatResult(); ``` -------------------------------- ### pjysdk.init(app_key, app_secret) Source: https://docs.paojiaoyun.com/lr_sdk.html Initializes the SDK with the application key and secret obtained from the developer console. ```APIDOC ## pjysdk.init(app_key, app_secret) ### Description Initializes the SDK with the application key and secret. ### Syntax ```lua pjysdk.init(app_key, app_secret) ``` ### Parameters - **app_key** (string) - Required - The application key from the developer console. - **app_secret** (string) - Required - The application secret from the developer console. ### Returns No return value. ``` -------------------------------- ### UserLogin syntax Source: https://docs.paojiaoyun.com/lr_sdk.html Calls pjysdk.UserLogin() to log in. Requires prior call to pjysdk.setUser(username, password). On success, a heartbeat thread starts automatically; use pjysdk.GetHeartbeatResult() to get heartbeat results. ```lua local ret = pjysdk.UserLogin() ``` -------------------------------- ### Initialize PJYSDK with appKey and appSecret Source: https://docs.paojiaoyun.com/uniapp_sdk.html Creates a new PJYSDK instance. Both appKey and appSecret are required strings obtained from the developer console. ```javascript const pjysdk = new PJYSDK(appKey, appSecret); ``` -------------------------------- ### Create SDK instance Source: https://docs.paojiaoyun.com/csharp_sdk.html Initializes the PJYSDK with appKey and appSecret. The SDK implements IDisposable and can be held long-term. ```csharp var sdk = new PJYSDK(appKey, appSecret); // 实现 IDisposable,可长期持有 ``` -------------------------------- ### Get Remote Data: PJYSDK.GetRemoteData Source: https://docs.paojiaoyun.com/ajjl_sdk.html Retrieves remote data by key. The key is a string with a maximum length of 64 characters. Returns a Table type, with an example response referenced from the interface response documentation. ```xojo ret = PJYSDK.GetRemoteData(key) ``` -------------------------------- ### Get Remote Variable: PJYSDK.GetRemoteVar Source: https://docs.paojiaoyun.com/ajjl_sdk.html Retrieves a remote variable by key. The key is a string with a maximum length of 64 characters. Returns a Table type, with an example response referenced from the interface response documentation. ```xojo ret = PJYSDK.GetRemoteVar(key) ``` -------------------------------- ### Initialize PJYSDK with appKey and appSecret Source: https://docs.paojiaoyun.com/android_sdk.html Creates a new PJYSDK instance. Both appKey and appSecret are required and obtained from the developer console. ```java PJYSDK pjysdk = new PJYSDK(String appKey, String appSecret); ``` -------------------------------- ### start.js 示例:初始化、登录、心跳处理与退出 Source: https://docs.paojiaoyun.com/aiwork_sdk.html 完整的 start.js 示例,展示如何初始化 PJYSDK、设置卡密、处理心跳失败、登录、退出和清理任务。使用前需将 PJYSDK.js 文件内容复制到文件顶部。AppKey 和 AppSecret 需在泡椒云开发者后台获取。心跳失败时,若 code 为 10214 则停止脚本,否则尝试重新登录。登录失败会停止脚本。示例中包含测试用的 setInterval 循环,需在实际使用时删除。 ```javascript /* ↑ 将PJYSDK.js文件中的代码复制粘贴到上面 ↑ */ // AppKey 和 AppSecret 在泡椒云开发者后台获取 let pjysdk = new PJYSDK('AppKey', 'AppSecret'); pjysdk.debug = true; pjysdk.SetCard('卡密'); // 心跳失败回调 pjysdk.onHeartbeatFailed(function(hret) { console.log('心跳失败 -> code: ' + hret.code + ' message: ' + hret.message); if (hret.code === 10214) { sleep.millisecond(200); stop(); // 退出脚本 return; } console.log('心跳失败,尝试重登...'); let login_ret = pjysdk.CardLogin(); if (login_ret.code === 0) { console.log('重登成功'); } else { console.log(login_ret.message); // 重登失败 sleep.millisecond(200); stop(); // 退出脚本 } }); event.onStopBtnEvent(function() { //pjysdk.CardLogout(); // 调用退出登录 pjysdk._clearTask(); // 清理定时心跳任务 console.log('结束运行'); }); function main() { let login_ret = pjysdk.CardLogin(); if (login_ret.code !== 0) { // 登录失败提示 console.log('登录失败: ' + login_ret.message); stop(); } // 登录成功,后面写你的业务代码 console.log(JSON.stringify(pjysdk.login_result, null, ' ')); // 测试用,hold住主线程不要退出,记得删除,后面应该是你的代码了 setInterval(() => { let ret = pjysdk.GetHeartbeatResult(); console.log('心跳结果: ' + ret.code + ' ' + ret.message); // toast(ret.code + " " + ret.message); }, 3000); } main(); ``` -------------------------------- ### 获取软件配置 - pjysdk.GetSoftwareConfig Source: https://docs.paojiaoyun.com/lr_sdk.html 调用 pjysdk.GetSoftwareConfig 接口,无参数,返回 Table 类型结果,具体返回结构参考接口返回示例。 ```lua local ret = pjysdk.GetSoftwareConfig() ``` -------------------------------- ### GET /v1/software/latest_ver Source: https://docs.paojiaoyun.com/software.html 获取软件最新版本。 ```APIDOC ## GET /v1/software/latest_ver ### Description 获取软件最新版本。 ### Method GET ### Endpoint http://api.paojiaoyun.com/v1/software/latest_ver ### Parameters #### Query Parameters - **app_key** (string) - Required - 软件的app_key - **nonce** (string) - Required - 不超过36位的随机字符串(建议用UUID) - **timestamp** (int64) - Required - 时间戳,秒级(10位数) - **version** (string) - Required - 软件当前的版本 - **sign** (string) - Required - 签名 ### Response #### Success Response (200) - **code** (int) - 返回码,0表示正确,详细参照返回码对照表。code返回 10304 时,表示已经是最新版本 - **message** (string) - 请求出错时的错误信息 - **result** (object) - 请求正确时,若有额外数据要返回,则结果封装在该字段。若无额外数据,则无此字段。 - **notice** (string) - 更新公告 - **url** (string) - 下载地址 - **version** (string) - 更新后的版本 - **server_time** (int) - 服务器当前时间戳,秒级(10位数) #### Response Example { "code": 0, // code返回 10304 时,表示已经是最新版本 "message": "ok", "result": { "notice": "v1.0.0正式发布,请及时更新。", "url": "https://www.xxx.com/uploads/xxx.apk", "version": "v1.0.0", "server_time": 1574654197 } } ``` -------------------------------- ### Initialize User Account with pjysdk.setUser(username, password) Source: https://docs.paojiaoyun.com/jsd_sdk.html Sets the user account credentials. Both username and password are required strings; username max length is 20 characters, password length must be between 6 and 30 characters. ```groovy pjysdk.setUser(username, password) ``` -------------------------------- ### C 版单头库引入(pjysdk.h) Source: https://docs.paojiaoyun.com/cpp_sdk.html 在 C 版接入中,需要在且仅在一个 .c 文件中定义宏 PJYSDK_IMPLEMENTATION 后再包含 pjysdk.h,以引入实现;其余文件只需 #include "pjysdk.h"。 ```c #define PJYSDK_IMPLEMENTATION #include "pjysdk.h" ``` -------------------------------- ### 在 .csproj 中引用 PJYSDK.dll Source: https://docs.paojiaoyun.com/csharp_sdk.html 在 SDK 风格工程中通过 Reference 和 HintPath 引用 PJYSDK.dll。 ```xml libs/PJYSDK.dll ``` -------------------------------- ### GET /v1/af/remote_data Source: https://docs.paojiaoyun.com/af.html 获取远程数据。需要提供app_key、key、nonce、timestamp和sign参数。 ```APIDOC ## GET /v1/af/remote_data ### Description 获取远程数据。 ### Method GET ### Endpoint http://api.paojiaoyun.com/v1/af/remote_data ### Parameters #### Query Parameters - **app_key** (string) - Required - 软件的app_key - **key** (string) - Required - 远程数据key(不超过64位字符) - **nonce** (string) - Required - 不超过36位的随机字符串(建议用UUID) - **timestamp** (int64) - Required - 时间戳,秒级(10位数) - **sign** (string) - Required - 签名 ### Response #### Success Response (200) - **code** (int) - 返回码,0表示正确,详细参照返回码对照表 - **message** (string) - 请求出错时的错误信息 - **result** (object) - 请求正确时,若有额外数据要返回,则结果封装在该字段。若无额外数据,则无此字段。 - **value** (string) - 远程数据值 #### Response Example { "code": 0, "message": "ok", "result": { "value": "123123" } } ``` -------------------------------- ### 试用退出登录 - PJYSDK.TrialLogout() Source: https://docs.paojiaoyun.com/ajjl_sdk.html 调用 PJYSDK.TrialLogout() 退出试用登录。返回 Table 类型,示例:{"code": 0, "message": "OK"}。 ```xojo ret = PJYSDK.TrialLogout() ``` -------------------------------- ### GET /v1/af/remote_var Source: https://docs.paojiaoyun.com/af.html 获取远程变量。需要提供app_key、key、nonce、timestamp和sign参数,如果远程变量设置了校验token,则还需要提供card和token参数。 ```APIDOC ## GET /v1/af/remote_var ### Description 获取远程变量。 ### Method GET ### Endpoint http://api.paojiaoyun.com/v1/af/remote_var ### Parameters #### Query Parameters - **app_key** (string) - Required - 软件的app_key - **card** (string) - Optional - 登录的卡密,如远程变量设置了校验token,则必传 - **key** (string) - Required - 远程变量名(不超过64位字符) - **nonce** (string) - Required - 不超过36位的随机字符串(建议用UUID) - **timestamp** (int64) - Required - 时间戳,秒级(10位数) - **token** (string) - Optional - 登录成功后返回的令牌,如远程变量设置了校验token,则必传 - **sign** (string) - Required - 签名 ### Response #### Success Response (200) - **code** (int) - 返回码,0表示正确,详细参照返回码对照表 - **message** (string) - 请求出错时的错误信息 - **result** (object) - 请求正确时,若有额外数据要返回,则结果封装在该字段。若无额外数据,则无此字段。 - **value** (string) - 远程变量值 #### Response Example { "code": 0, "message": "ok", "result": { "value": "123" } } ``` -------------------------------- ### GetSoftwareConfig Syntax Source: https://docs.paojiaoyun.com/ajjl_sdk.html Retrieves the software configuration. Takes no parameters and returns a Table type. ```xojo ret = PJYSDK.GetSoftwareConfig() ``` -------------------------------- ### 获取软件配置 - pjysdk.GetSoftwareConfig Source: https://docs.paojiaoyun.com/autojs_sdk.html 调用 pjysdk.GetSoftwareConfig 获取软件配置。无参数。返回 Object 类型,参考接口返回。 ```javascript let ret = pjysdk.GetSoftwareConfig(); ``` -------------------------------- ### 试用登录 - PJYSDK.TrialLogin() Source: https://docs.paojiaoyun.com/ajjl_sdk.html 调用 PJYSDK.TrialLogin() 进行试用登录。登录成功后会自动启动一个线程发送心跳包,开发者无需关注发送心跳包的细节,可通过 PJYSDK.GetHeartbeatResult() 获取心跳结果。返回 Table 类型。 ```xojo ret = PJYSDK.TrialLogin() ``` -------------------------------- ### 获取软件最新版本 - pjysdk.GetSoftwareLatestVersion Source: https://docs.paojiaoyun.com/autojs_sdk.html 调用 pjysdk.GetSoftwareLatestVersion 获取软件最新版本。参数 current_ver 为当前本地版本,长度不能超过 30 位。返回 Object 类型。 ```javascript let ret = pjysdk.GetSoftwareLatestVersion(current_ver); ``` -------------------------------- ### GetSoftwareLatestVersion syntax Source: https://docs.paojiaoyun.com/lr_sdk.html Calls pjysdk.GetSoftwareLatestVersion with the current local version string. The version length must not exceed 30 characters. Returns a Table type. ```lua local ret = pjysdk.GetSoftwareLatestVersion(current_ver) ``` -------------------------------- ### GetUserConfig - Get user configuration Source: https://docs.paojiaoyun.com/go_sdk.html Retrieves the user configuration. Returns a response with a UserConfigResult. ```go ret, err := pjysdk.GetUserConfig() // (*pjy.Resp[pjy.UserConfigResult], error) ``` -------------------------------- ### Set user account with set_user(username, password) Source: https://docs.paojiaoyun.com/py_sdk.html Sets the user's account credentials. Username must be a string up to 20 characters, password must be 6-30 characters. ```python pjysdk.set_user(username, password) ``` -------------------------------- ### Get remaining time with GetTimeRemaining Source: https://docs.paojiaoyun.com/go_sdk.html Returns the remaining valid time in seconds as an integer. ```go remaining := pjysdk.GetTimeRemaining() // int ``` -------------------------------- ### GetSoftwareLatestVersion Syntax Source: https://docs.paojiaoyun.com/ajjl_sdk.html Retrieves the latest software version. Requires a current version string parameter (max 30 characters) and returns a Table type. ```xojo ret = PJYSDK.GetSoftwareLatestVersion(current_ver) ``` -------------------------------- ### 创建 SDK (C++ 和 C) Source: https://docs.paojiaoyun.com/cpp_sdk.html 创建 SDK 实例。C++ 版本不可拷贝,可长期持有;C 版本使用 pjy_new 创建,退出时需调用 pjy_free 释放。 ```cpp pjy::PJYSDK sdk(appKey, appSecret); // C++(不可拷贝,可长期持有) pjy_sdk *s = pjy_new(app_key, app_secret); // C,退出时 pjy_free(s) ``` -------------------------------- ### Get network timestamp with pjysdk.timestamp() Source: https://docs.paojiaoyun.com/py_sdk.html Returns a numeric timestamp, e.g., 1602780478. No parameters required. ```python ts = pjysdk.timestamp() ``` -------------------------------- ### GetCardConfig - Get card configuration Source: https://docs.paojiaoyun.com/go_sdk.html Retrieves the card configuration. On success, the configuration is available in ret.Result.Config. ```go ret, err := pjysdk.GetCardConfig() // (*pjy.Resp[pjy.CardConfigResult], error) ``` -------------------------------- ### Create SDK Source: https://docs.paojiaoyun.com/cpp_sdk.html Creates a new SDK instance using the application key and secret. Available in both C++ and C APIs. ```APIDOC ## Create SDK ### Description Creates a new SDK instance using the application key and secret. ### Method Constructor / Factory function ### C++ Signature ```cpp pjy::PJYSDK sdk(appKey, appSecret); ``` ### C Signature ```c pjy_sdk *s = pjy_new(app_key, app_secret); ``` ### Parameters - **appKey** (string) - Required - The software's app_key, obtained from the developer console. - **appSecret** (string) - Required - The software's app_secret, obtained from the developer console. ### Notes - The C++ object is non-copyable and can be held long-term. - For C, call `pjy_free(s)` when done. ``` -------------------------------- ### GetTimeRemaining - Get remaining time Source: https://docs.paojiaoyun.com/jsd_sdk.html Returns a number representing remaining seconds, e.g., 1024. No parameters. ```groovy ret = pjysdk.GetTimeRemaining() ``` -------------------------------- ### Get remaining time (C++ and C) Source: https://docs.paojiaoyun.com/cpp_sdk.html Returns remaining valid seconds without making a network request. ```cpp int getTimeRemaining(); // C++ int pjy_get_time_remaining(pjy_sdk *s); // C ``` -------------------------------- ### GetSoftwareLatestVersion - Check for latest version Source: https://docs.paojiaoyun.com/uniapp_sdk.html Calls pjysdk.GetSoftwareLatestVersion(currentVer) with the current local version string (max 30 characters). On success, ret.result contains version, download_url, and update_log. ```javascript const ret = await pjysdk.GetSoftwareLatestVersion(currentVer); ``` -------------------------------- ### NewPJYSDK Source: https://docs.paojiaoyun.com/go_sdk.html Initializes the PaoJiaoYun SDK with the provided app key and app secret. ```APIDOC ## NewPJYSDK ### Description Initializes the PaoJiaoYun SDK with the provided app key and app secret. ### Method Constructor ### Signature `pjy.NewPJYSDK(appKey, appSecret string) *PJYSDK` ### Parameters - **appKey** (string) - Required - The software's app_key, obtained from the developer console. - **appSecret** (string) - Required - The software's app_secret, obtained from the developer console. ### Example ```go pjysdk := pjy.NewPJYSDK(appKey, appSecret) ``` ``` -------------------------------- ### pjysdk.GetSoftwareConfig() Source: https://docs.paojiaoyun.com/autojs_sdk.html Retrieves the software configuration. Takes no parameters and returns an object with the configuration data. ```APIDOC ## pjysdk.GetSoftwareConfig() ### Description Retrieves the software configuration. ### Syntax ```js let ret = pjysdk.GetSoftwareConfig(); ``` ### Parameters None. ### Return Value Object type, example: [参考接口返回](https://docs.paojiaoyun.com/software.html#%E5%93%8D%E5%BA%94%E7%A4%BA%E4%BE%8B) ``` -------------------------------- ### PJYSDK.Timestamp2() Source: https://docs.paojiaoyun.com/ajjl_sdk.html Returns the current timestamp as a numeric value. This method takes no parameters and is used to get the current Unix timestamp. ```APIDOC ## PJYSDK.Timestamp2() ### Description Returns the current timestamp as a numeric value. ### Method Function call ### Syntax ```xojo ret = PJYSDK.Timestamp2() ``` ### Parameters None ### Return Value Numeric type, e.g., 1602780478 ``` -------------------------------- ### Get remaining time with pjysdk.get_time_remaining() Source: https://docs.paojiaoyun.com/py_sdk.html Returns a numeric value representing remaining seconds, e.g., 1024. No parameters required. ```python ret = pjysdk.get_time_remaining() ``` -------------------------------- ### pjysdk.SetUser(username, password) Source: https://docs.paojiaoyun.com/autojs_sdk.html Initializes the SDK with a user account. Both username and password are required strings with specific length constraints. ```APIDOC ## pjysdk.SetUser(username, password) ### Description Initializes the SDK with a user account. ### Method SetUser ### Syntax ```js pjysdk.SetUser(username, password); ``` ### Parameters - **username** (string) - Required - Username (max length 20 characters). - **password** (string) - Required - User password (length 6-30 characters). ### Return Value None. ``` -------------------------------- ### Get Network Timestamp with pjysdk.getTimestamp() Source: https://docs.paojiaoyun.com/jsd_sdk.html Retrieves the network timestamp. Takes no parameters and returns a numeric value, e.g., 1602780478. ```groovy ret = pjysdk.getTimestamp() ``` -------------------------------- ### main.js 示例:初始化、登录、心跳与退出 Source: https://docs.paojiaoyun.com/ec_sdk.html 一个完整的 main.js 示例,展示如何初始化 PJYSDK、设置卡密、处理心跳失败、登录、退出和异常回调。注意:AppKey 和 AppSecret 需在泡椒云开发者后台获取;示例中的 while 循环仅用于测试,需删除。 ```javascript // AppKey 和 AppSecret 在泡椒云开发者后台获取 let pjysdk = new PJYSDK('AppKey', 'AppSecret'); pjysdk.debug = true; pjysdk.SetCard('卡密'); // 心跳失败回调 pjysdk.onHeartbeatFailed(function(hret) { logd(hret.message); if (hret.code === 10214) { sleep(200); setTimeout(exit, 100); // 退出脚本 return; } logd('心跳失败,2s后尝试重登...'); sleep(2000); let login_ret = pjysdk.CardLogin(); if (login_ret.code === 0) { logd('重登成功'); } else { logd(login_ret.message); // 重登失败 sleep(200); setTimeout(exit, 100); // 退出脚本 } }); setStopCallback(function() { pjysdk.CardLogout(); // 调用退出登录 logd('结束运行'); }); setExceptionCallback(function(msg) { pjysdk.CardLogout(); // 调用退出登录 logd(' 异常停止消息: ' + msg); }); function main() { let login_ret = pjysdk.CardLogin(); if (login_ret.code !== 0) { // 登录失败提示 toast(login_ret.message); setTimeout(exit, 100); // 退出脚本 return; } // 登录成功,后面写你的业务代码 logd(JSON.stringify(pjysdk.login_result, null, ' ')); // 测试用,hold住主线程不要退出,记得删除,后面应该是你的代码了 while (true) { let ret = pjysdk.GetHeartbeatResult(); logd('心跳结果: ' + ret.code + ' ' + ret.message); // toast(ret.code + " " + ret.message); sleep(2000); } } main(); ``` -------------------------------- ### GetSoftwareLatestVersion Source: https://docs.paojiaoyun.com/go_sdk.html Retrieves the latest software version. Requires the current local version string (max 30 characters). On success, ret.Result contains Version, Url, and Notice. ```go ret, err := pjysdk.GetSoftwareLatestVersion(currentVer string) // (*pjy.Resp[pjy.SoftwareVersionResult], error) ``` -------------------------------- ### Set user account with SetUser Source: https://docs.paojiaoyun.com/go_sdk.html Sets the user account with username and password. Both are required strings; username max length 20, password length 6-30. ```go pjysdk.SetUser(username, password string) ``` -------------------------------- ### 获取软件公告: pjysdk.get_software_notice() Source: https://docs.paojiaoyun.com/py_sdk.html Retrieves the software announcement. Takes no parameters. Returns a dictionary; see the referenced interface response for an example. ```python ret = pjysdk.get_software_notice() ``` -------------------------------- ### 卡密登录 - pjysdk.CardLogin() Source: https://docs.paojiaoyun.com/lr_sdk.html 调用此接口进行卡密登录。注意:调用前需先调用 pjysdk.setCard(card) 初始化卡密。登录成功后会自动启动线程发送心跳包,开发者可通过 GetHeartbeatResult() 获取心跳结果。返回 Table 类型,参考接口返回。 ```lua local ret = pjysdk.CardLogin() ``` -------------------------------- ### Initialize Card with pjysdk.setCard(card) Source: https://docs.paojiaoyun.com/jsd_sdk.html Sets the user's card (card key) for initialization. The card parameter is required and must be a string with a maximum length of 45 characters. ```groovy pjysdk.setCard(card) ``` -------------------------------- ### GetSoftwareNotice syntax Source: https://docs.paojiaoyun.com/jsd_sdk.html Groovy syntax for pjysdk.GetSoftwareNotice(). Takes no parameters. Returns an Object; see the referenced interface response for an example. ```groovy ret = pjysdk.GetSoftwareNotice() ``` -------------------------------- ### Get remaining time with getTimeRemaining Source: https://docs.paojiaoyun.com/android_sdk.html Returns the remaining valid seconds without making a network request. Can be called on the main thread. ```java long remaining = pjysdk.getTimeRemaining(); ``` -------------------------------- ### Initialize user account with pjysdk.SetUser Source: https://docs.paojiaoyun.com/autojs_sdk.html Sets the username and password for SDK initialization. Both parameters are required strings; username must not exceed 20 characters and password must be 6-30 characters. ```javascript pjysdk.SetUser(username, password); ``` -------------------------------- ### POST /v1/trial/login Source: https://docs.paojiaoyun.com/trial.html 用于试用登录,获取试用授权信息。需要提供app_key、device_id、nonce、timestamp和sign等参数。 ```APIDOC ## [POST] /v1/trial/login ### Description 用于试用登录,获取试用授权信息。 ### Method POST ### Endpoint http://api.paojiaoyun.com/v1/trial/login ### Parameters #### Request Body - **app_key** (string) - Required - 软件的app_key - **device_id** (string) - Required - 用户的设备唯一标识码 - **nonce** (string) - Required - 不超过36位的随机字符串(建议用UUID) - **timestamp** (int64) - Required - 时间戳,秒级(10位数) - **sign** (string) - Required - 签名 - **hg** (int64) - Optional - 推荐本地心跳间隔(秒)注意很多语言默认sleep是毫秒,则需将该值乘以1000 ### Response #### Success Response (200) - **code** (int) - 返回码,0表示正确,详细参照返回码对照表 - **message** (string) - 请求出错时的错误信息 - **result** (object) - 请求正确时,若有额外数据要返回,则结果封装在该字段。若无额外数据,则无此字段。 - **expires** (string) - 试用过期时间,格式化的 - **expires_ts** (int64) - 过期时间戳,秒级(10位数) - **server_time** (int64) - 服务器当前时间戳,秒级(10位数) #### Response Example { "code": 0, "message": "ok", "result": { "expires": "2020-10-16 00:47:58", "expires_ts": 1602780478, "server_time": 1574654197, "hg": 600 } } ``` -------------------------------- ### Get network timestamp with pjysdk.getTimestamp Source: https://docs.paojiaoyun.com/autojs_sdk.html Retrieves the current network timestamp. Takes no parameters and returns a numeric value, e.g., 1602780478. ```javascript let ret = pjysdk.getTimestamp(); ```