Package Exports
- wpcom
- wpcom/lib/me
- wpcom/lib/post
- wpcom/lib/site
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (wpcom) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
node-wpcom
WordPress API for nodejs
Layer to get resources from WordPress using the [developer.wordpress.com/docs/api/](REST API).
API
WPCOM();
Create a new instance of WPCOM. token
parameter is optional but it's needed to
make edition actions or to access to protected resources.
Note: If you wanna a way to get the access token then can use node-wpcom-oauth npm module.
var wpcom = require('wpcom')();
WPCOM#me.info();
var wpcom = require('wpcom')('<your token>');
// get the user info
wpcom.me.info(function(err, user){
// user info related with the given access token
});
WPCOM#site.info(params, fn);
Get the site information
var wpcom = require('wpcom')('<your token>');
// get site info
wpcom.site.id('blog.wordpress.com');
wpcom.site.info(function(err, site){
// site data object
});
Methods complete list
WPCOM#me
- #me.info(params, fn) Meta data about auth token's User
- #me.sites(params, fn) A list of the current user's sites
- #me.likes(params, fn) List the currently authorized user's likes
- #me.groups(params, fn) A list of the current user's group
- #me.connections(params, fn) A list of the current user's connections to third-party services
WPCOM#site
- #site.id(site_id) Set site id
- #site.info(params, fn) Information about site.id
- #site.posts(params, fn) Matching posts
WPCOM#site.post
- #site.post.get(id, params, fn) Return a single Post (by id)
- #site.post.getBySlug(slug, params, fn) Return a single Post (by id)
- #site.post.add(data, fn) Create a post
- #site.post.edit(id, data, fn) Edit a post
- #site.post.del(id, fn) Delete a post
Example
Into example/
folder download the npm dependencies:
$ npm install
... and then run the application
$ node index.js
Test
Create data.json
file into test/
folder to can run the tests. You can copy
or rename the test/data_example.json
file.
{
"client_id": "<your client_id here>",
"client_secret": "<your client_secret here>",
"token": "<your token app here>",
"public_site": "<a public blog here>",
"private_site": "<a private blog here>",
"private_site_id": "<the ID of the private blog>",
"new_post_data": {
"title": "New testing post",
"content": "<div style=\"color: red;\">The content of the new testing post</div>"
}
}
... and then
$ make
License
MIT – Copyright 2014 Automattic