wp-connect
Wordpress connect module
Layer to get resources from WordPress using the developer.wordpress.com/docs/api/.
API
WPCONN();
Create a new instance of WPCONN. If you wanna a way to get the access token then can use WPOAuth npm module.
var WPCONN = ;var wpconn = ;
WPCONN#me();
var WPCONN = ;var wpconn = '<your token>'; // get the user infowpconn;
WPCONN#site.id();
Set site identifier
WPCONN#site.info(params, fn);
Get the site information
var WPCONN = ;var wpconn = '<your token here>'; // get site infowpconnsiteid'blog.wordpress.com';wpconnsite;
WPCONN#site.posts(params, fn);
Get the site posts
wpconnsiteid'blog.wordpress.com';wpconnsite;
WPCONN.site.post.get(id, fn);
Get post site data
// get post datawpconnsitepost;
WPCONN.site.post.getBySlug(slug, params, fn);
Get post site data by the given slug
// get post datawpconnsitepost;
WPCONN.site.post.add(data, fn);
Add a new post
// post datavar data = "title": "A new post" "slug": "a-new-post" "content": "<div>The content of the new post</div>"; wpconnsitepost;
WPCONN.site.post.edit(id, data, fn);
Edit a post
wpconnsitepost;
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.
... and then
$ make
License
MIT – Copyright 2014 Automattic