Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Compatibility with node 0.3.8

  • Loading branch information...
commit 98e432b4318c6f4af420b9c8399a32e47c1ecb5b 1 parent 0a786bd
@rsms rsms authored ciaranj committed
Showing with 30 additions and 27 deletions.
  1. +26 −23 examples/term.ie.oauth-PLAINTEXT.js
  2. +4 −4 lib/oauth.js
View
49 examples/term.ie.oauth-PLAINTEXT.js
@@ -2,30 +2,33 @@ var sys= require('sys')
var OAuth= require('../lib/oauth').OAuth;
-var oa= new OAuth("http://term.ie/oauth/example/request_token.php?foo=bar",
- "http://term.ie/oauth/example/access_token.php",
- "key",
- "secret",
- "1.0",
- null,
- "PLAINTEXT")
+var oa = new OAuth("http://term.ie/oauth/example/request_token.php?foo=bar",
+ "http://term.ie/oauth/example/access_token.php",
+ "key",
+ "secret",
+ "1.0",
+ null,
+ "PLAINTEXT")
oa.getOAuthRequestToken(function(error, oauth_token, oauth_token_secret, results){
- if(error) sys.puts('error :' + error)
- else {
- sys.puts('oauth_token :' + oauth_token)
- sys.puts('oauth_token_secret :' + oauth_token_secret)
- sys.puts('requestoken results :' + sys.inspect(results))
- sys.puts("Requesting access token")
- oa.getOAuthAccessToken(oauth_token, oauth_token_secret, function(error, oauth_access_token, oauth_access_token_secret, results2) {
- sys.puts('oauth_access_token :' + oauth_access_token)
- sys.puts('oauth_token_secret :' + oauth_access_token_secret)
- sys.puts('accesstoken results :' + sys.inspect(results2))
- sys.puts("Requesting access token")
- var data= "";
- oa.getProtectedResource("http://term.ie/oauth/example/echo_api.php?foo=bar&too=roo", "GET", oauth_access_token, oauth_access_token_secret, function (error, data, response) {
- sys.puts(data);
- });
+ if (error) return console.log('error :' + error)
+ console.log('oauth_token :' + oauth_token)
+ console.log('oauth_token_secret :' + oauth_token_secret)
+ console.log('requestoken results :', results)
+ console.log("Requesting access token")
+ oa.getOAuthAccessToken(oauth_token, oauth_token_secret,
+ function(error, oauth_access_token,
+ oauth_access_token_secret, results2) {
+ console.log('oauth_access_token :' + oauth_access_token)
+ console.log('oauth_token_secret :' + oauth_access_token_secret)
+ console.log('accesstoken results :', results2)
+ console.log("Requesting access token")
+ var data= "";
+ oa.getProtectedResource(
+ "http://term.ie/oauth/example/echo_api.php?foo=bar&too=roo", "GET",
+ oauth_access_token, oauth_access_token_secret,
+ function (error, data, response) {
+ console.log(data);
});
- }
+ });
})
View
8 lib/oauth.js
@@ -289,12 +289,12 @@ exports.OAuth.prototype._performSecureRequest= function( oauth_token, oauth_toke
if( callback ) {
var data="";
var self= this;
- request.addListener('response', function (response) {
+ request.on('response', function (response) {
response.setEncoding('utf8');
- response.addListener('data', function (chunk) {
+ response.on('data', function (chunk) {
data+=chunk;
});
- response.addListener('end', function () {
+ response.on('end', function () {
if( response.statusCode != 200 ) {
callback({ statusCode: response.statusCode, data: data });
} else {
@@ -303,7 +303,7 @@ exports.OAuth.prototype._performSecureRequest= function( oauth_token, oauth_toke
});
});
- request.socket.addListener("error",callback);
+ request.on("error", callback);
if( (method == "POST" || method =="PUT") && post_body != null && post_body != "" ) {
request.write(post_body);
Please sign in to comment.
Something went wrong with that request. Please try again.