From 8badc6b806fd48395c56835084691584cc2c85d8 Mon Sep 17 00:00:00 2001 From: oskosk Date: Fri, 24 Feb 2017 09:42:27 -0300 Subject: [PATCH] Update usage instructions to be clearer on how to use the access token and add example querying site list --- README.md | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 39da4ba..ae4c03f 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,10 @@ var wpcomOAuth = require('wpcom-oauth-cors')(''); // get auth object wpcomOAuth.get(function(auth){ - // your token is here auth.access_token! + // Here, your token is available as auth.access_token + // e.g.: + // var wpcom = require('wpcom'); + // var wpc = wpcom(auth.access_token); }); // clean stored token @@ -53,6 +56,27 @@ Create a wpcomOAuth instance giving `client_id` (String) and optional parameters ### wpcomOAuth.token() + +## Example + +This snippet will log a posts array from site with id `123456`. + +```js +var wpcom = require('wpcom'); +var wpcomOAuth = require('wpcom-oauth-cors')(''); + +// get auth object +wpcomOAuth.get(function(auth){ + // Here, your token is available as auth.access_token + var wpc = wpcom( auth.access_token ); + var mySite = wpc.site( 123456 ); + mySite.postsList({ number: 50, fields: "author,URL,title,geo" }, function(err, list) { + console.log( list ); + }); +}); + +``` + ## Test * Compile testing js file