[wordpress插件] Catenis API Client for WordPress适用于WordPress的Catenis API客户端

wordpress 插件 文章 2020-03-18 21:40 479 0 全屏看文

AI助手支持GPT4.0

评分
0
描述

Catenis API Client for WordPress enables (JavaScript) code on WordPress pages to interact with the Catenis Enterprise API.

适用于WordPress的Catenis API客户端使WordPress页面上的(JavaScript)代码能够与Catenis Enterprise API进行交互。

Enabling the Catenis API client

启用Catenis API客户端

To enable the Catenis API client for a given WordPress page, go to the page’s edit page and look for a section (meta box) named “Catenis API Client” below the page’s main editing panel.

要为给定的WordPress页面启用Catenis API客户端,请转到页面的编辑页面,然后在页面的主编辑面板下查找名为“ Catenis API Client”的部分(元框)。

Make sure the section is expanded, and check the Load Catenis API Client checkbox.

确保该部分已展开,并选中加载Catenis API客户端复选框。

You can then choose to override the global settings used for instantiating the Catenis API client on that given page, like using a different device ID and its associated API access secret.

然后,您可以选择覆盖用于在给定页面上实例化Catenis API客户端的全局设置,例如使用其他设备ID及其关联的API访问密码。

Otherwise, whatever is configured in the plugin’s global settings — configured under “Settings” |

否则,插件全局设置中配置的所有内容-在“设置” |

“Catenis API Client” — is going to be used.

将使用“ Catenis API客户端”。

Using the Catenis API client

使用Catenis API客户端

Once enabled, a global JavaScript variable named ctnApiClient is made available on the page.

启用后,将在页面上提供名为 ctnApiClient 的全局JavaScript变量。

That variable holds the instantiated Catenis API client object.

该变量保存实例化的Catenis API客户端对象。

Use the ctnApiClient variable to call the Catenis Enterprise API methods by invoking the corresponding method on that object.

使用 ctnApiClient 变量通过在该对象上调用相应的方法来调用Catenis Enterprise API方法。

For a reference of the available methods, please refer to the Catenis API JavaScript Client as it is functionally

有关可用方法的参考,请从功能上参考 Catenis API JavaScript客户端

identical to the Catenis API Client for WordPress, except for notifications support and error handling.

除了通知支持和错误处理之外,与Catenis API for WordPress相同。

Notifications support

通知支持

The notification feature on Catenis API Client for WordPress is almost identical to the one found on the Catenis API JavaScript client.

Catenis API Client for WordPress的通知功能几乎与Catenis API JavaScript客户端上的通知功能相同。

The two noticeable differences are:

两个明显的区别是:

    1. The Catenis API client object can emit a comm-error event.
    2. Catenis API客户端对象可以发出 comm-error 事件。

    3. The open event emitted by the WebSocket notification channel object may return an error.
    4. WebSocket通知通道对象发出的 open 事件可能返回错误。

    Please refer to the “Receiving Notifications” section below for detailed information on how to receive Catenis notifications from within WordPress pages.

    有关如何从WordPress页面内接收Catenis通知的详细信息,请参阅下面的“接收通知”部分。

    Error handling

    错误处理

    Errors that take place while calling the Catenis API methods are returned as standard JavaScript Error objects.

    调用Catenis API方法时发生的错误将作为标准JavaScript错误对象返回。

    Receiving Notifications

    接收通知

    = Instantiate WebSocket notification channel object

    =实例化WebSocket通知通道对象

    Create a WebSocket notification channel for a given Catenis notification event.

    为给定的Catenis通知事件创建WebSocket通知通道。

    var wsNotifyChannel = ctnApiClient.createWsNotifyChannel(eventName);

      var wsNotifyChannel = ctnApiClient.createWsNotifyChannel(eventName);

    Add listeners

    添加听众

    Add event listeners to monitor activity on the notification channel.

    添加事件监听器以监视通知通道上的活动。

    ctnApiClient.on('comm-error', function (error) {    

      ctnApiClient.on('comm-error',function(error){    

    // Error communicating with Catenis notification process

    //与Catenis通知流程通信时出错

    });

    });

    wsNotifyChannel.on('open', function (error) {    

    wsNotifyChannel.on('open',function(error){    

    if (error) {        

    如果(错误){        

    // Error establishing underlying WebSocket connection    

    //建立基础WebSocket连接时出错    

    }    

    }    

    else {        

    其他{        

    // Notification channel successfully open    

    //通知频道成功打开    

    }

    }

    });

    });

    wsNotifyChannel.on('error', function (error) {    

    wsNotifyChannel.on('错误',函数(错误){    

    // Error in the underlying WebSocket connection

    //基础WebSocket连接中的错误

    });

    });

    wsNotifyChannel.on('close', function (code, reason) {    

    wsNotifyChannel.on('close',函数(代码,原因){    

    // Underlying WebSocket connection has been closed

    //基础WebSocket连接已关闭

    });

    });

    wsNotifyChannel.on('notify', function (eventData) {    

    wsNotifyChannel.on('notify',function(eventData){    

    // Received notification

    //收到通知

    });

    });

    Note: the ‘comm-error’ event is emitted by the Catenis API client object while all other events are emitted by the WebSocket notification channel object.

    注意:“通信错误”事件是由Catenis API客户端对象发出的,而所有其他事件都是由WebSocket通知通道对象发出的。

    Open the notification channel

    打开通知通道

    Open the WebSocket notification channel to start receiving notifications.

    打开WebSocket通知通道以开始接收通知。

    wsNotifyChannel.open(function (error) {    

      wsNotifyChannel.open(function(error){    

    if (err) {        

    如果(错误){        

    // Error sending command to open notification channel    

    //错误发送命令以打开通知通道    

    }

    }

    });

    });

    Close the notification channel

    关闭通知频道

    Close the WebSocket notification channel to stop receiving notifications.

    关闭WebSocket通知通道以停止接收通知。

    wsNotifyChannel.close(function (error) {    

      wsNotifyChannel.close(function(error){    

    if (err) {        

    如果(错误){        

    // Error sending command to close notification channel    

    //错误发送命令以关闭通知通道    

    }

    }

    });

    });

安装步骤

System requirements

系统要求

The PHP executable should be in the system PATH so that the plugin can spawn the process used to handle notifications.

PHP可执行文件应位于系统PATH中,以便插件可以产生用于处理通知的过程。

Installation procedure

安装过程

    1. Upload the plugin files to the “/wp-content/plugins/” directory.
    2. 将插件文件上传到“ / wp-content / plugins /”目录。

    3. Activate the plugin through the “Plugins” menu in WordPress.
    4. 通过WordPress中的“插件”菜单激活插件。

    5. Go to “Settings” |

    6. 转到“设置” |

      “Catenis API Client” to configure the global settings for instantiating the Catenis API client.

    7. “ Catenis API客户端”配置用于实例化Catenis API客户端的全局设置。

    8. A meta box named “Catenis API Client” will be available on every WordPress page’s edit page.

    9. 每个WordPress页面的编辑页面上都将提供一个名为“ Catenis API Client”的元框。

      Use it to make the Catenis API client available from a given page, and optionally configure custom settings for instantiating the Catenis API client for that given page.

    10. 使用它可以使Catenis API客户端可从给定页面访问,并可以选择配置自定义设置以实例化该给定页面的Catenis API客户端。

    Please refer to Catenis Enterprise API documentation for further information on accessing the Catenis Enterprise API.<

    有关访问Catenis Enterprise API的更多信息,请参考 Catenis Enterprise API文档。<

    /p>

    / p>

下载地址
https://downloads.wordpress.org/plugin/catenis-api-client.2.0.0.zip
-EOF-

AI助手支持GPT4.0