Code Monkey home page Code Monkey logo

inwx-nodejs's Introduction

inwx-nodejs

A Node.js client to connect to inwx XML-RPC API.

Installation

npm install inwx

Official Documentation from InternetWorX

You can view a detailed description of the API functions in our documentation. The documentation as PDF ist part of the Projekt. You also can read the documentation online http://www.inwx.de/en/help/apidoc

Prerequisites

  • For the production API, you need an account at https://www.inwx.de
  • For the testing API, register a new account at https://ote.inwx.de. You won't be able to use your standard credentials from inwx.de!

Usage

var inwx = require('inwx');

// set api to production or testing
inwx({api: "testing", user: "max123", password: "pass123"}, function(api){
  console.log("API is ready");

  // get account infos
  api.call("account", "info", {}, function(response){
    console.log("account.info response:");
    console.log(response);
  });

  // SOA serial numbers are updated by INWX automatically!

  // create record in nameserver set and delete again
  // using helper methods
  // make sure the nameserver for example.com already exists!!
  api.nameserverRecordHelper("example.com", "create", {type: "A", name: "test.example.com", content: "192.168.0.1"}, function(response) {
    console.log("created record:");
    console.log(response);

    // so, lets delete it
    api.nameserverRecordHelper("example.com", "delete", {type: "A", name: "test.example.com", content: "192.168.0.1"}, function(response) {
      console.log("deleted record:");
      console.log(response);
    });  
  });  

  // update record in nameserver   
  api.nameserverRecordHelper("example.com", "update", {content: "192.168.0.2"}, {type: "A", name: "sub.example.com"}, function(response) {
    console.log("updated record sub.example.com with 192.168.0.2:");
    console.log(response);
  });   

  // be aware that calls are made asynchronously! call api.close() when all other calls terminated.
  // api.close(); // logout 
});

See example.js for more examples.

License (MIT)

Released under the MIT license. See the LICENSE file for the complete wording.

inwx-nodejs's People

Contributors

kekskurse avatar lorenz avatar mattes avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

inwx-nodejs's Issues

npm installs old version

When installed via npm the last pull request (or more?) is not included. Therefore, the library is then broken.

API does not work - this.client.methodCall response never retrieved

I tried your codesample, but the API is ready message never comes:

inwx({api: "production", user: "myusername", password: "mypassword"}, function(api){
  console.log("API is ready");

Trying with testing api produces the error (but OK, I don't even have an testing API account and don't known how to make one, so..):

4|inwx     | Error
4|inwx     |     at ClientRequest.<anonymous> 
 (/home/myusername/nodejs_apps/node_modules/inwx/lib/inwx.js:62:15)
4|inwx     |     at emitOne (events.js:77:13)
4|inwx     |     at ClientRequest.emit (events.js:169:7)
4|inwx     |     at Socket.socketErrorListener (_http_client.js:258:9)
4|inwx     |     at emitOne (events.js:77:13)
4|inwx     |     at Socket.emit (events.js:169:7)
4|inwx     |     at emitErrorNT (net.js:1256:8)
4|inwx     |     at nextTickCallbackWith2Args (node.js:441:9)
4|inwx     |     at process._tickDomainCallback (node.js:396:17)
PM2        | App [inwx] with id [4] and pid [12695], exited with code [1] via signal [SIGINT]

Trying with production API, I looked into the node_modules/inwx/lib/inwx.js file and tried out some console.log messages to get an idea of where the problem is.

function inwx(opts, readyCallback) {
 ...
  this.client = xmlrpc.createClient({ host: opts.host, isSecure: true, path: "/xmlrpc/", cookies: true });

  console.log("inwx.js: so far 1"); // is called successfully

  this.call("account", "login", {user: opts.user, pass: opts.password}, function(response) {
    console.log("inwx.js: connected!"); // never called!!!
    this.connected = true;
    readyCallback.call(this, that);
  });

  return that;
}

inwx.prototype.call = function call(object, method, params, successCallback, errorCallback) {
  if(!object) throw new Error("missing object for xmlrpc call");
  if(!method) throw new Error("missing method for xmlrpc call");

  console.log("inwx.js: so far 2"); // is called successfully

  this.client.methodCall(object + "." + method, [ params ], function(error, response){
    console.log("inwx.js: so far 3"); // never called!!!
    if(error) {

So apparently the callback function of this.client.methodCall is never called.

Tested on fresh Ubuntu 16.04 LTS server (nodejs v4.2.6) and fresh Ubuntu 17.10 desktop (nodejs v6.11.4). freshly installed NodeJS via:

cd ~ && mkdir nodejs_apps && cd nodejs_apps
sudo apt-get install nodejs npm build-essential
sudo ln -s "$(which nodejs)" /usr/bin/node
sudo npm install express
sudo npm install body-parser
sudo npm install request
sudo npm install pm2 -g
sudo npm install inwx
working with pm2 to run the app

Full example app is here: https://pastebin.com/bhdREpNf

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.