Update Readme.md
added OAuth 1.0 example
This commit is contained in:
parent
11ed5943ee
commit
08569a220a
33
Readme.md
33
Readme.md
@ -18,9 +18,38 @@ Examples
|
|||||||
|
|
||||||
To run examples/tests insall Mocha `$ npm install -g mocha` and run `$ mocha you-file-name.js`:
|
To run examples/tests insall Mocha `$ npm install -g mocha` and run `$ mocha you-file-name.js`:
|
||||||
|
|
||||||
|
## OAuth1.0
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
describe('OAuth',function(){
|
describe('OAuth1.0',function(){
|
||||||
var request = require('superagent');
|
var OAuth = require('OAuth');
|
||||||
|
|
||||||
|
it('tests trends Twitter API v1.1',function(done){
|
||||||
|
var oauth = new OAuth.OAuth(
|
||||||
|
'https://api.twitter.com/oauth/request_token',
|
||||||
|
'https://api.twitter.com/oauth/access_token',
|
||||||
|
"your application consumer key',
|
||||||
|
"your application secret",
|
||||||
|
'1.0A',
|
||||||
|
null,
|
||||||
|
'HMAC-SHA1'
|
||||||
|
);
|
||||||
|
oauth.get(
|
||||||
|
'https://api.twitter.com/1.1/trends/place.json?id=23424977',
|
||||||
|
"your user toke for this app", //test user token
|
||||||
|
"your user secret for this app", //test user secret
|
||||||
|
function (e, data, res){
|
||||||
|
if (e) console.error(e);
|
||||||
|
console.log(require('util').inspect(data));
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
## OAuth2.0
|
||||||
|
```javascript
|
||||||
|
describe('OAuth2',function(){
|
||||||
var OAuth = require('OAuth');
|
var OAuth = require('OAuth');
|
||||||
|
|
||||||
it('gets bearer token', function(done){
|
it('gets bearer token', function(done){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user