Created
February 14, 2016 14:59
-
-
Save pirosuke/dac13be45fcc9fc38295 to your computer and use it in GitHub Desktop.
Node.js XMLRPC Client Sample
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"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" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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