UNPKG

910 BMarkdownView Raw
1
2# WPCOM
3
4### WPCOM('token');
5
6Create a new instance of WPCOM. `token` parameter is optional but it's needed to
7make admin actions or to access to protected resources.
8
9**Note**: You can use the [node-wpcom-oauth][] module to get an _access token_.
10
11### WPCOM#me(fn)
12
13Create a `Me` object. More info in [Me doc page](./me.md).
14
15```js
16var wpcom = require('wpcom')('<your-token>');
17var me = wpcom.me();
18});
19```
20
21### WPCOM#site('site-id')
22
23Create a `Site` object. More info in [Site doc page](./site.md).
24
25```js
26var wpcom = require('wpcom')('<your-token>');
27var site = wpcom.site();
28```
29
30### WPCOM#freshlyPressed([params, ]fn)
31
32View Freshly Pressed posts from the WordPress.com homepage.
33
34```js
35wpcom.freshlyPressed(function(err, data){
36 if (err) throw err;
37 console.log('"Freshly Pressed" Posts:');
38 data.posts.forEach(function (post) {
39 console.log(' %s - %s', post.title, post.short_URL);
40 });
41});
42```