Skip to content

Instantly share code, notes, and snippets.

@pirosuke
Created Feb 14, 2016
Embed
What would you like to do?
Node.js XMLRPC Client Sample
var xmlrpc = require('xmlrpc');
var Hatebu = {};
Hatebu.getHatebuCount = function (domain, callback) {
var client = xmlrpc.createClient({
host: "b.hatena.ne.jp",
path: "/xmlrpc"
});
client.methodCall('bookmark.getTotalCount', [domain], function (error, value) {
if (error) {
callback(error);
return;
}
callback(value);
});
};
module.exports = Hatebu;
{
"name": "hatebu-counter",
"version": "0.1.0",
"description": "hatebu-counter",
"main": "hatebu.js",
"scripts": {
"test": "echo \"Error: no test specified! Configure in package.json\" && exit 1"
},
"repository": "",
"keywords": [],
"author": "",
"license": "MIT",
"readmeFilename": "README.md",
"devDependencies": {
"xmlrpc": "^1.3.1"
}
}
var Hatebu = require('./hatebu');
// Show hatebu count of https://gist.github.com
Hatebu.getHatebuCount('https://gist.github.com', function (result) {
console.log("gist.github.com:" + result);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment