1.1.2 • Published 10 years ago
hackerpub v1.1.2
hackerpub
Post items to Hacker News
Installation
$ npm install --save hackerpubUsage
The example shown below will post a link on HackerNews.
var hackerpub = require('hackerpub');
hackerpub({
username: '{{your HN username}}',
password: '{{your HN password}}',
title: 'Example Blog Article',
url: 'http://exampleblog.com/articles/example-blog-article'
}, done);
function done (err, res, body, discuss) {
// handle response
}API
hackerpub(options, done)
Posts an article on HN by making a series of requests against their website. Takes some options, detailed below.
| Property | Description |
|---|---|
username | Your HackerNews username, used to authenticate, and to post the news on your behalf |
password | Your HackerNews password, used to authenticate |
title | A title for the news item |
url | The URL to the news item |
text | A description of the news item |
Note that url and text are exclusive. If you include both, the url will take precedence and the text will be ignored.
When the requests against HN are done, the done callback will be invoked with four arguments.
errwill have an error if one occurred, andnullotherwisereswill be a response objectbodywill be the response bodydiscusswill be a link to the discussion on Hacker News
CLI
The CLI has a simple interface. You'll be asked for your credentials once, and they'll be stored at ~/.hpub. You can edit that file directly, the CLI expects YAML.
$ cat ~/.hpubusername: foo,
password: foo$ hpub -t "some title" -u http://exampleblog.com -x "some text"
> https://news.ycombinator.com/item?id=$YOUR_HN_DISCUSSIONCLI Usage
Usage:
hpub <options>
Options:
-t, --title | Title for the news item
-u, --url, --uri | URL to the news item
-x, --text | Text describing the news item
Note that you should use either an URL or the --text option.License
MIT