Skip to content

Instantly share code, notes, and snippets.

@pirosuke
Created February 14, 2016 14:59
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save pirosuke/dac13be45fcc9fc38295 to your computer and use it in GitHub Desktop.
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