node-twitter-api
Advanced tools
Comparing version 1.2.4 to 1.3.0
{ | ||
"name": "node-twitter-api", | ||
"version": "1.2.4", | ||
"version": "1.3.0", | ||
"description": "Simple module for using Twitter's API in node.js", | ||
"keywords": ["twitter","oauth","rest","streaming"], | ||
"keywords": ["twitter", "oauth", "rest", "streaming"], | ||
"homepage": "https://github.com/reneraab/node-twitter-api", | ||
@@ -7,0 +7,0 @@ "author": "René Raab", |
385
twitter.js
@@ -1,2 +0,2 @@ | ||
var VERSION = "1.2.4", | ||
var VERSION = "1.3.0", | ||
querystring = require("querystring"), | ||
@@ -25,3 +25,3 @@ oauth = require("oauth"), | ||
Twitter.prototype.getRequestToken = function(callback) { | ||
this.oa.getOAuthRequestToken(function(error, oauthToken, oauthTokenSecret, results){ | ||
this.oa.getOAuthRequestToken(function(error, oauthToken, oauthTokenSecret, results) { | ||
if (error) { | ||
@@ -46,7 +46,11 @@ callback(error); | ||
Twitter.prototype.verifyCredentials = function(accessToken, accessTokenSecret, callback) { | ||
this.oa.get(baseUrl + "account/verify_credentials.json", accessToken, accessTokenSecret, function (error, data, response) { | ||
this.oa.get(baseUrl + "account/verify_credentials.json", accessToken, accessTokenSecret, function(error, data, response) { | ||
if (error) { | ||
callback(error); | ||
} else { | ||
callback(null, JSON.parse(data)); | ||
try { | ||
callback(null, JSON.parse(data)); | ||
} catch (e) { | ||
callback(e, data); | ||
} | ||
} | ||
@@ -62,3 +66,3 @@ }); | ||
var url; | ||
switch(type) { | ||
switch (type) { | ||
case "home_timeline": | ||
@@ -89,7 +93,11 @@ case "home": | ||
this.oa.get(baseUrl + "statuses/" + url + ".json?" + querystring.stringify(params), accessToken, accessTokenSecret, function (error, data, response) { | ||
this.oa.get(baseUrl + "statuses/" + url + ".json?" + querystring.stringify(params), accessToken, accessTokenSecret, function(error, data, response) { | ||
if (error) { | ||
callback(error); | ||
} else { | ||
callback(null, JSON.parse(data)); | ||
try { | ||
callback(null, JSON.parse(data)); | ||
} catch (e) { | ||
callback(e, data); | ||
} | ||
} | ||
@@ -104,3 +112,3 @@ }); | ||
var url, method = "GET"; | ||
switch(type) { | ||
switch (type) { | ||
case "userstream": | ||
@@ -136,5 +144,5 @@ case "user": | ||
var msg = []; | ||
req.addListener("response", function (res) { | ||
req.addListener("response", function(res) { | ||
res.setEncoding("utf-8"); | ||
res.addListener("data", function (chunk) { | ||
res.addListener("data", function(chunk) { | ||
if (chunk == "\r\n") { | ||
@@ -144,6 +152,6 @@ dataCallback(null, {}, chunk, res); | ||
} else if (chunk.substr(chunk.length - 2) == "\r\n") { | ||
msg.push(chunk.substr(0, chunk.length -2)); | ||
msg.push(chunk.substr(0, chunk.length - 2)); | ||
var ret = msg.join(""); | ||
msg = []; | ||
var parsedRet; | ||
@@ -153,3 +161,6 @@ try { | ||
} catch (e) { | ||
dataCallback({ message: "Error while parsing Twitter-Response.", error: e }, null, chunk, res); | ||
dataCallback({ | ||
message: "Error while parsing Twitter-Response.", | ||
error: e | ||
}, null, chunk, res); | ||
return; | ||
@@ -178,3 +189,3 @@ } | ||
var method = "GET"; | ||
switch(type) { | ||
switch (type) { | ||
case "retweets": | ||
@@ -185,3 +196,3 @@ url = "retweets/" + params.id; | ||
case "show": | ||
url = "show/"+params.id; | ||
url = "show/" + params.id; | ||
delete params.id; | ||
@@ -194,3 +205,3 @@ break; | ||
case "destroy": | ||
url = "destroy/"+params.id; | ||
url = "destroy/" + params.id; | ||
delete params.id; | ||
@@ -203,3 +214,3 @@ method = "POST"; | ||
case "retweet": | ||
url = "retweet/"+params.id; | ||
url = "retweet/" + params.id; | ||
delete params.id; | ||
@@ -217,15 +228,23 @@ method = "POST"; | ||
if (method == "GET") { | ||
this.oa.get(baseUrl + "statuses/" + url + ".json?" + querystring.stringify(params), accessToken, accessTokenSecret, function (error, data, response) { | ||
this.oa.get(baseUrl + "statuses/" + url + ".json?" + querystring.stringify(params), accessToken, accessTokenSecret, function(error, data, response) { | ||
if (error) { | ||
callback(error, response, baseUrl + "statuses/" + url + ".json?" + querystring.stringify(params)); | ||
callback(error, data, response, baseUrl + "statuses/" + url + ".json?" + querystring.stringify(params)); | ||
} else { | ||
callback(null, JSON.parse(data), response); | ||
try { | ||
callback(null, JSON.parse(data), response); | ||
} catch (e) { | ||
callback(e, data, response); | ||
} | ||
} | ||
}); | ||
} else { | ||
this.oa.post(baseUrl + "statuses/" + url + ".json", accessToken, accessTokenSecret, params, function (error, data, response) { | ||
this.oa.post(baseUrl + "statuses/" + url + ".json", accessToken, accessTokenSecret, params, function(error, data, response) { | ||
if (error) { | ||
callback(error, response); | ||
callback(error, data, response); | ||
} else { | ||
callback(null, JSON.parse(data), response); | ||
try { | ||
callback(null, JSON.parse(data), response); | ||
} catch (e) { | ||
callback(e, data, response); | ||
} | ||
} | ||
@@ -247,5 +266,9 @@ }); | ||
if (error) { | ||
callback(error, response, baseUrl + "statuses/update_with_media.json?" + querystring.stringify(params)); | ||
callback(error, body, response, baseUrl + "statuses/update_with_media.json?" + querystring.stringify(params)); | ||
} else { | ||
callback(null, JSON.parse(body), response); | ||
try { | ||
callback(null, JSON.parse(body), response); | ||
} catch (e) { | ||
callback(e, body, response); | ||
} | ||
} | ||
@@ -277,7 +300,11 @@ }); | ||
Twitter.prototype.search = function(params, accessToken, accessTokenSecret, callback) { | ||
this.oa.get(baseUrl + "search/tweets.json?" + querystring.stringify(params), accessToken, accessTokenSecret, function (error, data, response) { | ||
this.oa.get(baseUrl + "search/tweets.json?" + querystring.stringify(params), accessToken, accessTokenSecret, function(error, data, response) { | ||
if (error) { | ||
callback(error, response, baseUrl + "search/tweets.json?" + querystring.stringify(params)); | ||
callback(error, data, response, baseUrl + "search/tweets.json?" + querystring.stringify(params)); | ||
} else { | ||
callback(null, JSON.parse(data), response); | ||
try { | ||
callback(null, JSON.parse(data), response); | ||
} catch (e) { | ||
callback(e, data, response); | ||
} | ||
} | ||
@@ -296,15 +323,23 @@ }); | ||
if (method == "GET") { | ||
this.oa.get(baseUrl + "users/" + url + ".json?" + querystring.stringify(params), accessToken, accessTokenSecret, function (error, data, response) { | ||
this.oa.get(baseUrl + "users/" + url + ".json?" + querystring.stringify(params), accessToken, accessTokenSecret, function(error, data, response) { | ||
if (error) { | ||
callback(error, response, baseUrl + "users/" + url + ".json?" + querystring.stringify(params)); | ||
callback(error, data, response, baseUrl + "users/" + url + ".json?" + querystring.stringify(params)); | ||
} else { | ||
callback(null, JSON.parse(data), response); | ||
try { | ||
callback(null, JSON.parse(data), response); | ||
} catch (e) { | ||
callback(e, data, response); | ||
} | ||
} | ||
}); | ||
} else { | ||
this.oa.post(baseUrl + "users/" + url + ".json", accessToken, accessTokenSecret, params, function (error, data, response) { | ||
this.oa.post(baseUrl + "users/" + url + ".json", accessToken, accessTokenSecret, params, function(error, data, response) { | ||
if (error) { | ||
callback(error, response); | ||
callback(error, data, response); | ||
} else { | ||
callback(null, JSON.parse(data), response); | ||
try { | ||
callback(null, JSON.parse(data), response); | ||
} catch (e) { | ||
callback(e, data, response); | ||
} | ||
} | ||
@@ -321,7 +356,11 @@ }); | ||
this.oa.get(baseUrl + "friends/" + url + ".json?" + querystring.stringify(params), accessToken, accessTokenSecret, function (error, data, response) { | ||
this.oa.get(baseUrl + "friends/" + url + ".json?" + querystring.stringify(params), accessToken, accessTokenSecret, function(error, data, response) { | ||
if (error) { | ||
callback(error, response, baseUrl + "friends/" + url + ".json?" + querystring.stringify(params)); | ||
callback(error, data, response, baseUrl + "friends/" + url + ".json?" + querystring.stringify(params)); | ||
} else { | ||
callback(null, JSON.parse(data), response); | ||
try { | ||
callback(null, JSON.parse(data), response); | ||
} catch (e) { | ||
callback(e, data, response); | ||
} | ||
} | ||
@@ -335,7 +374,11 @@ }); | ||
this.oa.get(baseUrl + "followers/" + url + ".json?" + querystring.stringify(params), accessToken, accessTokenSecret, function (error, data, response) { | ||
this.oa.get(baseUrl + "followers/" + url + ".json?" + querystring.stringify(params), accessToken, accessTokenSecret, function(error, data, response) { | ||
if (error) { | ||
callback(error, response, baseUrl + "folllowers/" + url + ".json?" + querystring.stringify(params)); | ||
callback(error, data, response, baseUrl + "folllowers/" + url + ".json?" + querystring.stringify(params)); | ||
} else { | ||
callback(null, JSON.parse(data), response); | ||
try { | ||
callback(null, JSON.parse(data), response); | ||
} catch (e) { | ||
callback(e, data, response); | ||
} | ||
} | ||
@@ -351,3 +394,3 @@ }); | ||
// define endpoints that use POST | ||
switch(type) { | ||
switch (type) { | ||
case "create": | ||
@@ -361,15 +404,23 @@ case "destroy": | ||
if (method == "GET") { | ||
this.oa.get(baseUrl + "friendships/" + url + ".json?" + querystring.stringify(params), accessToken, accessTokenSecret, function (error, data, response) { | ||
this.oa.get(baseUrl + "friendships/" + url + ".json?" + querystring.stringify(params), accessToken, accessTokenSecret, function(error, data, response) { | ||
if (error) { | ||
callback(error, response, baseUrl + "friendships/" + url + ".json?" + querystring.stringify(params)); | ||
callback(error, data, response, baseUrl + "friendships/" + url + ".json?" + querystring.stringify(params)); | ||
} else { | ||
callback(null, JSON.parse(data), response); | ||
try { | ||
callback(null, JSON.parse(data), response); | ||
} catch (e) { | ||
callback(e, data, response); | ||
} | ||
} | ||
}); | ||
} else { | ||
this.oa.post(baseUrl + "friendships/" + url + ".json", accessToken, accessTokenSecret, params, function (error, data, response) { | ||
this.oa.post(baseUrl + "friendships/" + url + ".json", accessToken, accessTokenSecret, params, function(error, data, response) { | ||
if (error) { | ||
callback(error, response); | ||
callback(error, data, response); | ||
} else { | ||
callback(null, JSON.parse(data), response); | ||
try { | ||
callback(null, JSON.parse(data), response); | ||
} catch (e) { | ||
callback(e, data, response); | ||
} | ||
} | ||
@@ -394,5 +445,9 @@ }); | ||
if (error) { | ||
callback(error, response, baseUrl + "account/update_profile_image.json?" + querystring.stringify(params)); | ||
callback(error, body, response, baseUrl + "account/update_profile_image.json?" + querystring.stringify(params)); | ||
} else { | ||
callback(null, JSON.parse(body), response); | ||
try { | ||
callback(null, JSON.parse(body), response); | ||
} catch (e) { | ||
callback(e, body, response); | ||
} | ||
} | ||
@@ -418,3 +473,3 @@ }); | ||
var method = "POST"; | ||
switch(url) { | ||
switch (url) { | ||
case "settings": | ||
@@ -434,15 +489,23 @@ if (Object.keys(params).length === 0) { | ||
if (method == "GET") { | ||
this.oa.get(baseUrl + "account/" + url + ".json?" + querystring.stringify(params), accessToken, accessTokenSecret, function (error, data, response) { | ||
this.oa.get(baseUrl + "account/" + url + ".json?" + querystring.stringify(params), accessToken, accessTokenSecret, function(error, data, response) { | ||
if (error) { | ||
callback(error, response, baseUrl + "account/" + url + ".json?" + querystring.stringify(params)); | ||
callback(error, data, response, baseUrl + "account/" + url + ".json?" + querystring.stringify(params)); | ||
} else { | ||
callback(null, JSON.parse(data), response); | ||
try { | ||
callback(null, JSON.parse(data), response); | ||
} catch (e) { | ||
callback(e, data, response); | ||
} | ||
} | ||
}); | ||
} else { | ||
this.oa.post(baseUrl + "account/" + url + ".json", accessToken, accessTokenSecret, params, function (error, data, response) { | ||
this.oa.post(baseUrl + "account/" + url + ".json", accessToken, accessTokenSecret, params, function(error, data, response) { | ||
if (error) { | ||
callback(error, response); | ||
callback(error, data, response); | ||
} else { | ||
callback(null, JSON.parse(data), response); | ||
try { | ||
callback(null, JSON.parse(data), response); | ||
} catch (e) { | ||
callback(e, data, response); | ||
} | ||
} | ||
@@ -458,3 +521,3 @@ }); | ||
var method = "GET"; | ||
switch(url) { | ||
switch (url) { | ||
case "create": | ||
@@ -467,15 +530,23 @@ case "destroy": | ||
if (method == "GET") { | ||
this.oa.get(baseUrl + "blocks/" + url + ".json?" + querystring.stringify(params), accessToken, accessTokenSecret, function (error, data, response) { | ||
this.oa.get(baseUrl + "blocks/" + url + ".json?" + querystring.stringify(params), accessToken, accessTokenSecret, function(error, data, response) { | ||
if (error) { | ||
callback(error, response, baseUrl + "blocks/" + url + ".json?" + querystring.stringify(params)); | ||
callback(error, data, response, baseUrl + "blocks/" + url + ".json?" + querystring.stringify(params)); | ||
} else { | ||
callback(null, JSON.parse(data), response); | ||
try { | ||
callback(null, JSON.parse(data), response); | ||
} catch (e) { | ||
callback(e, data, response); | ||
} | ||
} | ||
}); | ||
} else { | ||
this.oa.post(baseUrl + "blocks/" + url + ".json", accessToken, accessTokenSecret, params, function (error, data, response) { | ||
this.oa.post(baseUrl + "blocks/" + url + ".json", accessToken, accessTokenSecret, params, function(error, data, response) { | ||
if (error) { | ||
callback(error, response); | ||
callback(error, data, response); | ||
} else { | ||
callback(null, JSON.parse(data), response); | ||
try { | ||
callback(null, JSON.parse(data), response); | ||
} catch (e) { | ||
callback(e, data, response); | ||
} | ||
} | ||
@@ -490,7 +561,11 @@ }); | ||
this.oa.get(baseUrl + "users/" + url + ".json?" + querystring.stringify(params), accessToken, accessTokenSecret, function (error, data, response) { | ||
this.oa.get(baseUrl + "users/" + url + ".json?" + querystring.stringify(params), accessToken, accessTokenSecret, function(error, data, response) { | ||
if (error) { | ||
callback(error, response, baseUrl + "users/" + url + ".json?" + querystring.stringify(params)); | ||
callback(error, data, response, baseUrl + "users/" + url + ".json?" + querystring.stringify(params)); | ||
} else { | ||
callback(null, JSON.parse(data), response); | ||
try { | ||
callback(null, JSON.parse(data), response); | ||
} catch (e) { | ||
callback(e, data, response); | ||
} | ||
} | ||
@@ -505,3 +580,3 @@ }); | ||
switch(url) { | ||
switch (url) { | ||
case "suggestions": | ||
@@ -521,7 +596,11 @@ case "": | ||
this.oa.get(baseUrl + "users/suggestions" + ((url) ? "/" + url : "") + ".json?" + querystring.stringify(params), accessToken, accessTokenSecret, function (error, data, response) { | ||
this.oa.get(baseUrl + "users/suggestions" + ((url) ? "/" + url : "") + ".json?" + querystring.stringify(params), accessToken, accessTokenSecret, function(error, data, response) { | ||
if (error) { | ||
callback(error, response, baseUrl + "users/suggestions" + ((url) ? "/" + url : "") + ".json?" + querystring.stringify(params)); | ||
callback(error, data, response, baseUrl + "users/suggestions" + ((url) ? "/" + url : "") + ".json?" + querystring.stringify(params)); | ||
} else { | ||
callback(null, JSON.parse(data), response); | ||
try { | ||
callback(null, JSON.parse(data), response); | ||
} catch (e) { | ||
callback(e, data, response); | ||
} | ||
} | ||
@@ -536,3 +615,3 @@ }); | ||
switch(url) { | ||
switch (url) { | ||
case "destroy": | ||
@@ -544,15 +623,23 @@ case "create": | ||
if (method == "GET") { | ||
this.oa.get(baseUrl + "favorites/" + url + ".json?" + querystring.stringify(params), accessToken, accessTokenSecret, function (error, data, response) { | ||
this.oa.get(baseUrl + "favorites/" + url + ".json?" + querystring.stringify(params), accessToken, accessTokenSecret, function(error, data, response) { | ||
if (error) { | ||
callback(error, response, baseUrl + "favorites/" + url + ".json?" + querystring.stringify(params)); | ||
callback(error, data, response, baseUrl + "favorites/" + url + ".json?" + querystring.stringify(params)); | ||
} else { | ||
callback(null, JSON.parse(data), response); | ||
try { | ||
callback(null, JSON.parse(data), response); | ||
} catch (e) { | ||
callback(e, data, response); | ||
} | ||
} | ||
}); | ||
} else { | ||
this.oa.post(baseUrl + "favorites/" + url + ".json", accessToken, accessTokenSecret, params, function (error, data, response) { | ||
this.oa.post(baseUrl + "favorites/" + url + ".json", accessToken, accessTokenSecret, params, function(error, data, response) { | ||
if (error) { | ||
callback(error, response); | ||
callback(error, data, response); | ||
} else { | ||
callback(null, JSON.parse(data), response); | ||
try { | ||
callback(null, JSON.parse(data), response); | ||
} catch (e) { | ||
callback(e, data, response); | ||
} | ||
} | ||
@@ -569,3 +656,3 @@ }); | ||
switch(url) { | ||
switch (url) { | ||
case "direct_messages": | ||
@@ -581,15 +668,23 @@ case "": | ||
if (method == "GET") { | ||
this.oa.get(baseUrl + "direct_messages" + ((url) ? "/" + url : "") + ".json?" + querystring.stringify(params), accessToken, accessTokenSecret, function (error, data, response) { | ||
this.oa.get(baseUrl + "direct_messages" + ((url) ? "/" + url : "") + ".json?" + querystring.stringify(params), accessToken, accessTokenSecret, function(error, data, response) { | ||
if (error) { | ||
callback(error, response, baseUrl + "direct_messages" + ((url) ? "/" + url : "") + ".json?" + querystring.stringify(params)); | ||
callback(error, data, response, baseUrl + "direct_messages" + ((url) ? "/" + url : "") + ".json?" + querystring.stringify(params)); | ||
} else { | ||
callback(null, JSON.parse(data), response); | ||
try { | ||
callback(null, JSON.parse(data), response); | ||
} catch (e) { | ||
callback(e, data, response); | ||
} | ||
} | ||
}); | ||
} else { | ||
this.oa.post(baseUrl + "direct_messages/" + url + ".json", accessToken, accessTokenSecret, params, function (error, data, response) { | ||
this.oa.post(baseUrl + "direct_messages/" + url + ".json", accessToken, accessTokenSecret, params, function(error, data, response) { | ||
if (error) { | ||
callback(error, response); | ||
callback(error, data, response); | ||
} else { | ||
callback(null, JSON.parse(data), response); | ||
try { | ||
callback(null, JSON.parse(data), response); | ||
} catch (e) { | ||
callback(e, data, response); | ||
} | ||
} | ||
@@ -605,3 +700,3 @@ }); | ||
switch(url) { | ||
switch (url) { | ||
case "members/destroy": | ||
@@ -620,15 +715,23 @@ case "members/destroy_all": | ||
if (method == "GET") { | ||
this.oa.get(baseUrl + "lists/" + url + ".json?" + querystring.stringify(params), accessToken, accessTokenSecret, function (error, data, response) { | ||
this.oa.get(baseUrl + "lists/" + url + ".json?" + querystring.stringify(params), accessToken, accessTokenSecret, function(error, data, response) { | ||
if (error) { | ||
callback(error, response, baseUrl + "lists/" + url + ".json?" + querystring.stringify(params)); | ||
callback(error, data, response, baseUrl + "lists/" + url + ".json?" + querystring.stringify(params)); | ||
} else { | ||
callback(null, JSON.parse(data), response); | ||
try { | ||
callback(null, JSON.parse(data), response); | ||
} catch (e) { | ||
callback(e, data, response); | ||
} | ||
} | ||
}); | ||
} else { | ||
this.oa.post(baseUrl + "lists/" + url + ".json", accessToken, accessTokenSecret, params, function (error, data, response) { | ||
this.oa.post(baseUrl + "lists/" + url + ".json", accessToken, accessTokenSecret, params, function(error, data, response) { | ||
if (error) { | ||
callback(error, response); | ||
callback(error, data, response); | ||
} else { | ||
callback(null, JSON.parse(data), response); | ||
try { | ||
callback(null, JSON.parse(data), response); | ||
} catch (e) { | ||
callback(e, data, response); | ||
} | ||
} | ||
@@ -661,15 +764,23 @@ }); | ||
if (method == "GET") { | ||
this.oa.get(baseUrl + "saved_searches/" + url + ".json?" + querystring.stringify(params), accessToken, accessTokenSecret, function (error, data, response) { | ||
this.oa.get(baseUrl + "saved_searches/" + url + ".json?" + querystring.stringify(params), accessToken, accessTokenSecret, function(error, data, response) { | ||
if (error) { | ||
callback(error, response, baseUrl + "saved_searches/" + url + ".json?" + querystring.stringify(params)); | ||
callback(error, data, response, baseUrl + "saved_searches/" + url + ".json?" + querystring.stringify(params)); | ||
} else { | ||
callback(null, JSON.parse(data), response); | ||
try { | ||
callback(null, JSON.parse(data), response); | ||
} catch (e) { | ||
callback(e, data, response); | ||
} | ||
} | ||
}); | ||
} else { | ||
this.oa.post(baseUrl + "saved_searches/" + url + ".json", accessToken, accessTokenSecret, params, function (error, data, response) { | ||
this.oa.post(baseUrl + "saved_searches/" + url + ".json", accessToken, accessTokenSecret, params, function(error, data, response) { | ||
if (error) { | ||
callback(error, response); | ||
callback(error, data, response); | ||
} else { | ||
callback(null, JSON.parse(data), response); | ||
try { | ||
callback(null, JSON.parse(data), response); | ||
} catch (e) { | ||
callback(e, data, response); | ||
} | ||
} | ||
@@ -696,15 +807,23 @@ }); | ||
if (method == "GET") { | ||
this.oa.get(baseUrl + "geo/" + url + ".json?" + querystring.stringify(params), accessToken, accessTokenSecret, function (error, data, response) { | ||
this.oa.get(baseUrl + "geo/" + url + ".json?" + querystring.stringify(params), accessToken, accessTokenSecret, function(error, data, response) { | ||
if (error) { | ||
callback(error, response, baseUrl + "geo/" + url + ".json?" + querystring.stringify(params)); | ||
callback(error, data, response, baseUrl + "geo/" + url + ".json?" + querystring.stringify(params)); | ||
} else { | ||
callback(null, JSON.parse(data), response); | ||
try { | ||
callback(null, JSON.parse(data), response); | ||
} catch (e) { | ||
callback(e, data, response); | ||
} | ||
} | ||
}); | ||
} else { | ||
this.oa.post(baseUrl + "geo/" + url + ".json", accessToken, accessTokenSecret, params, function (error, data, response) { | ||
this.oa.post(baseUrl + "geo/" + url + ".json", accessToken, accessTokenSecret, params, function(error, data, response) { | ||
if (error) { | ||
callback(error, response); | ||
callback(error, data, response); | ||
} else { | ||
callback(null, JSON.parse(data), response); | ||
try { | ||
callback(null, JSON.parse(data), response); | ||
} catch (e) { | ||
callback(e, data, response); | ||
} | ||
} | ||
@@ -719,7 +838,11 @@ }); | ||
this.oa.get(baseUrl + "trends/" + url + ".json?" + querystring.stringify(params), accessToken, accessTokenSecret, function (error, data, response) { | ||
this.oa.get(baseUrl + "trends/" + url + ".json?" + querystring.stringify(params), accessToken, accessTokenSecret, function(error, data, response) { | ||
if (error) { | ||
callback(error, response, baseUrl + "trends/" + url + ".json?" + querystring.stringify(params)); | ||
callback(error, data, response, baseUrl + "trends/" + url + ".json?" + querystring.stringify(params)); | ||
} else { | ||
callback(null, JSON.parse(data), response); | ||
try { | ||
callback(null, JSON.parse(data), response); | ||
} catch (e) { | ||
callback(e, data, response); | ||
} | ||
} | ||
@@ -733,7 +856,11 @@ }); | ||
this.oa.post(baseUrl + "users/report_spam.json", accessToken, accessTokenSecret, params, function (error, data, response) { | ||
this.oa.post(baseUrl + "users/report_spam.json", accessToken, accessTokenSecret, params, function(error, data, response) { | ||
if (error) { | ||
callback(error, response); | ||
callback(error, data, response); | ||
} else { | ||
callback(null, JSON.parse(data), response); | ||
try { | ||
callback(null, JSON.parse(data), response); | ||
} catch (e) { | ||
callback(e, data, response); | ||
} | ||
} | ||
@@ -765,15 +892,23 @@ }); | ||
if (method == "GET") { | ||
this.oa.get(baseUrl + url + ".json?" + querystring.stringify(params), accessToken, accessTokenSecret, function (error, data, response) { | ||
this.oa.get(baseUrl + url + ".json?" + querystring.stringify(params), accessToken, accessTokenSecret, function(error, data, response) { | ||
if (error) { | ||
callback(error, response, baseUrl + "geo/" + url + ".json?" + querystring.stringify(params)); | ||
callback(error, data, response, baseUrl + "geo/" + url + ".json?" + querystring.stringify(params)); | ||
} else { | ||
callback(null, JSON.parse(data), response); | ||
try { | ||
callback(null, JSON.parse(data), response); | ||
} catch (e) { | ||
callback(e, data, response); | ||
} | ||
} | ||
}); | ||
} else { | ||
this.oa.post(baseUrl + url + ".json", accessToken, accessTokenSecret, params, function (error, data, response) { | ||
this.oa.post(baseUrl + url + ".json", accessToken, accessTokenSecret, params, function(error, data, response) { | ||
if (error) { | ||
callback(error, response); | ||
callback(error, data, response); | ||
} else { | ||
callback(null, JSON.parse(data), response); | ||
try { | ||
callback(null, JSON.parse(data), response); | ||
} catch (e) { | ||
callback(e, data, response); | ||
} | ||
} | ||
@@ -788,7 +923,11 @@ }); | ||
this.oa.get(baseUrl + "help/" + url + ".json?" + querystring.stringify(params), accessToken, accessTokenSecret, function (error, data, response) { | ||
this.oa.get(baseUrl + "help/" + url + ".json?" + querystring.stringify(params), accessToken, accessTokenSecret, function(error, data, response) { | ||
if (error) { | ||
callback(error, response, baseUrl + "help/" + url + ".json?" + querystring.stringify(params)); | ||
callback(error, data, response, baseUrl + "help/" + url + ".json?" + querystring.stringify(params)); | ||
} else { | ||
callback(null, JSON.parse(data), response); | ||
try { | ||
callback(null, JSON.parse(data), response); | ||
} catch (e) { | ||
callback(e, data, response); | ||
} | ||
} | ||
@@ -800,7 +939,11 @@ }); | ||
Twitter.prototype.rateLimitStatus = function(params, accessToken, accessTokenSecret, callback) { | ||
this.oa.get(baseUrl + "application/rate_limit_status.json?" + querystring.stringify(params), accessToken, accessTokenSecret, function (error, data, response) { | ||
this.oa.get(baseUrl + "application/rate_limit_status.json?" + querystring.stringify(params), accessToken, accessTokenSecret, function(error, data, response) { | ||
if (error) { | ||
callback(error, response, baseUrl + "application/rate_limit_status.json?" + querystring.stringify(params)); | ||
callback(error, data, response, baseUrl + "application/rate_limit_status.json?" + querystring.stringify(params)); | ||
} else { | ||
callback(null, JSON.parse(data), response); | ||
try { | ||
callback(null, JSON.parse(data), response); | ||
} catch (e) { | ||
callback(e, data, response); | ||
} | ||
} | ||
@@ -807,0 +950,0 @@ }); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
30876
828