Browse files

Redirect is no longer required. Jslinted a little bit

  • Loading branch information...
1 parent abc4eec commit af637750d21c6f6d9b0824ca1c8e21cb98fcfbe0 @masylum committed Mar 11, 2011
Showing with 18 additions and 11 deletions.
  1. +1 −1 Readme.md
  2. +8 −6 lib/twitter_client.js
  3. +1 −1 package.json
  4. +8 −3 test/client.js
View
2 Readme.md
@@ -18,7 +18,7 @@ Params must contain the token.
var express = require('express'),
connect = require('connect');
- var twitterClient = require('./../')('yourKey', 'yourPass', 'http://twitter-js.com:3003/'),
+ var twitterClient = require('./../')('yourKey', 'yourPass'),
app = express.createServer(
connect.bodyParser(),
connect.cookieParser(),
View
14 lib/twitter_client.js
@@ -12,7 +12,7 @@ var url = require("url"),
OAuth = require('oauth').OAuth,
querystring = require("querystring");
-module.exports = function (api_key, api_secret, redirect) {
+module.exports = function (api_key, api_secret) {
var client = {version: '0.0.3'},
// PRIVATE
@@ -22,7 +22,7 @@ module.exports = function (api_key, api_secret, redirect) {
api_key,
api_secret,
'1.0',
- redirect || false,
+ false,
'HMAC-SHA1',
null,
{'Accept': '*/*', 'Connection': 'close', 'User-Agent': 'twitter-js ' + client.version}
@@ -66,12 +66,14 @@ module.exports = function (api_key, api_secret, redirect) {
client.getAccessToken = function (req, res, callback) {
- var parsedUrl = url.parse(req.url, true)
- , protocol = (req.socket.encrypted ? 'https' : 'http' )
- , callbackUrl = protocol + '://' + req.headers.host + parsedUrl.pathname;
+ var parsedUrl = url.parse(req.url, true),
+ protocol = req.socket.encrypted ? 'https' : 'http',
+ callbackUrl = protocol + '://' + req.headers.host + parsedUrl.pathname,
+ has_token = parsedUrl.query && parsedUrl.query.oauth_token,
+ has_secret = req.session.auth && req.session.auth.twitter_oauth_token_secret;
// Acces token
- if (parsedUrl.query && parsedUrl.query.oauth_token && req.session.auth && req.session.auth.twitter_oauth_token_secret) {
+ if (has_token && has_secret) {
oAuth.getOAuthAccessToken(
parsedUrl.query.oauth_token,
View
2 package.json
@@ -1,7 +1,7 @@
{
"name": "twitter-js",
"description": "easy peasy twitter client",
- "version": "0.0.6",
+ "version": "0.0.7",
"author": "Pau Ramon <masylum@gmail.com>",
"keywords": ["twitter"],
"main" : "lib/twitter_client.js",
View
11 test/client.js
@@ -8,8 +8,7 @@ var express = require('express'),
connect = require('connect'),
twitterClient = require('./../')(
'yourKey',
- 'yourPass',
- 'http://twitter-js.com:3003/'
+ 'yourPass'
),
app = express.createServer(
connect.bodyParser(),
@@ -34,7 +33,13 @@ app.post('/message', function (req, res) {
twitterClient.apiCall(
'POST',
'/statuses/update.json',
- {token: {oauth_token_secret: req.param('oauth_token_secret'), oauth_token: req.param('oauth_token'), status: req.param('message')}},
+ {
+ token: {
+ oauth_token_secret: req.param('oauth_token_secret'),
+ oauth_token: req.param('oauth_token'),
+ status: req.param('message')
+ }
+ },
function (error, result) {
console.log(error);
console.log(result);

2 comments on commit af63775

@gerad

thanks for the cleanup! i'll keep my style jslint compatible going forward.

@masylum
Owner

thanks for your pull requests in the first place. :)

Please sign in to comment.