首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >我可以在Node.js中使用PaperCut (XML-RPC) API吗?

我可以在Node.js中使用PaperCut (XML-RPC) API吗?
EN

Stack Overflow用户
提问于 2020-09-21 03:58:35
回答 1查看 288关注 0票数 0

我打算使用XML,尽管据我所知,PaperCut -RPC不支持Node.JS,或者我找不到合适的客户机来实现这个目的。下面是与PaperCut接口的链接:https://www.papercut.com/support/resources/manuals/ng-mf/common/topics/tools-web-services.html

我想知道谁能够让它在JavaScript中工作。我在QNAP中使用Node.js (在集装箱车站)。如果它可以在Python中运行,我应该安装Python容器吗?我可以使用Python中的一段代码向Node.js请求它吗?

EN

回答 1

Stack Overflow用户

发布于 2020-12-18 12:37:45

我在PaperCut软件公司工作

很抱歉,我花了这么长时间才回复这篇文章,但我最终找到了一个空闲的下午来拼凑一些代码。

代码语言:javascript
复制
var xmlrpc = require('xmlrpc')

const authToken = 'token'

const hostAddress = "172.24.96.1"
 
// Waits briefly to give the XML-RPC server time to start up and start
// listening
setTimeout(function () {
  // Creates an XML-RPC client. Passes the host information on where to
  // make the XML-RPC calls.
  var client = xmlrpc.createClient({ host: hostAddress, port: 9191, path: '/rpc/api/xmlrpc'})
 
  // Sends a method call to the PaperCut MF/NG server

  client.methodCall(`api.${process.argv[2]}`, [authToken].concat(process.argv.slice(3)), function (error, value) {
    // Results of the method response
    if (undefined === error || null === error) {
        console.log(`Method response for \'${process.argv[2]}\': ${value}`)
    }
    else
    {
        console.log(`Error response for \'${process.argv[2]}\': ${error}`)
    }
  })
 
}, 1000)

要从命令行运行此命令,请尝试执行以下命令

代码语言:javascript
复制
node main.js getUserProperty alec balance
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63983125

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档