Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ var wpcomOAuth = require('wpcom-oauth-cors')('<client-id>');

// 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
Expand Down Expand Up @@ -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')('<client-id>');

// 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
Expand Down