Skip to content
This repository has been archived by the owner on Feb 13, 2018. It is now read-only.

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
reneraab committed Nov 18, 2012
1 parent 2ea2e57 commit ebafc12
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 0 deletions.
7 changes: 7 additions & 0 deletions LICENSE
@@ -0,0 +1,7 @@
Copyright (c) 2012 René Raab (renner96)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1 change: 1 addition & 0 deletions index.js
@@ -0,0 +1 @@
module.exports = require('./twitter');
23 changes: 23 additions & 0 deletions package.json
@@ -0,0 +1,23 @@
{
"name": "node-twitter-api",
"version": "0.0.1",
"description": "Simple module for using Twitter's API in node.js",
"keywords": ["twitter","oauth"],
"homepage": "https://github.com/renner96/node-twitter",
"author": "René Raab (renner96)",
"licenses": {
"type": "MIT",
"url": "https://raw.github.com/renner96/node-twitter/master/LICENSE"
},
"repository": {
"type": "git",
"url": "https://github.com/renner96/node-twitter.git"
},
"dependencies": {
"oauth": ">=0.8.4"
},
"engines": {
"node": ">=0.4.0"
},
"main": "./twitter"
}
50 changes: 50 additions & 0 deletions twitter.js
@@ -0,0 +1,50 @@
var VERSION = '0.0.1',
oauth = require('oauth');


var Twitter = function(options) {
if (!(this instanceof Twitter))
return new Twitter(options);

this.consumerKey = options.consumerKey;
this.consumerSecret = options.consumerSecret;
this.callback = options.callback;

this.oa = new oauth.OAuth("https://twitter.com/oauth/request_token", "https://twitter.com/oauth/access_token",
this.consumerKey, this.consumerSecret, "1.0A", this.callback, "HMAC-SHA1");

return this;
}
Twitter.VERSION = VERSION;

Twitter.prototype.getRequestToken = function(callback) {
this.oa.getOAuthRequestToken(function(error, oauthToken, oauthTokenSecret, results){
if (error) {
callback(error);
} else {
callback(null, oauthToken, oauthTokenSecret, results);
}
});
}

Twitter.prototype.getAccessToken = function(requestToken, requestTokenSecret, oauth_verifier, callback) {
this.oa.getOAuthAccessToken(requestToken, requestTokenSecret, oauth_verifier, function(error, oauthAccessToken, oauthAccessTokenSecret, results) {
if (error) {
callback(error);
} else {
callback(null, oauthAccessToken, oauthAccessTokenSecret, results);
}
});
}

Twitter.prototype.verifyCredentials = function (accessToken, accessTokenSecret, callback) {
this.oa.get("https://api.twitter.com/1.1/account/verify_credentials.json", accessToken, accessTokenSecret, function (error, data, response) {
if (error) {
callback(error);
} else {
callback(null, JSON.parse(data), null);
}
});
}

module.exports = Twitter;

0 comments on commit ebafc12

Please sign in to comment.