Skip to content

Commit e600c20

Browse files
committed
Update usage instructions to be clearer on how to use the access token and add example querying site list
1 parent 8c8f274 commit e600c20

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

README.md

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@ var wpcomOAuth = require('wpcom-oauth-cors')('<client-id>');
1919

2020
// get auth object
2121
wpcomOAuth.get(function(auth){
22-
// your token is here auth.access_token!
22+
// Here, your token is available as auth.access_token
23+
// e.g.:
24+
// var wpcom = require('wpcom');
25+
// var wpc = wpcom(auth.access_token);
26+
2327
});
2428

2529
// clean stored token
@@ -53,6 +57,29 @@ Create a wpcomOAuth instance giving `client_id` (String) and optional parameters
5357

5458
### wpcomOAuth.token()
5559

60+
61+
## Example
62+
63+
This snippet will log a posts array from site with id `123456`.
64+
65+
```js
66+
var wpcom = require('wpcom');
67+
var wpcomOAuth = require('wpcom-oauth-cors')('<client-id>');
68+
69+
// get auth object
70+
wpcomOAuth.get(function(auth){
71+
// your token is available
72+
// in auth.access_token
73+
var wpc = wpcom( auth.access_token );
74+
var mySite = wpc.site( 123456 );
75+
mySite.postsList({ number: 50, fields: "author,URL,title,geo" }, function(err, list) {
76+
console.log( list );
77+
});
78+
79+
});
80+
81+
```
82+
5683
## Test
5784

5885
* Compile testing js file

0 commit comments

Comments
 (0)