Permalink
Browse files

Merge pull request #1 from tonyto/master

deprecated auth endpoint
  • Loading branch information...
2 parents c0c091a + 2fac9c1 commit fa279b2998acdacf5d04b10d90bffec609c178d4 @andzdroid committed Aug 18, 2011
Showing with 41 additions and 20 deletions.
  1. +2 −0 .gitignore
  2. +8 −0 examples/config/index.sample.js
  3. +13 −0 examples/spec_site.js
  4. +13 −0 examples/spec_user.js
  5. +5 −20 lib/posterous.js
View
@@ -1,3 +1,5 @@
*.swo
*.swp
tests/config/index.js
+*.log
+
@@ -0,0 +1,8 @@
+//To run the tests, rename this file to index.js
+//and fill in your posterous account details
+
+module.exports = {
+ user: '',
+ pass: ''
+ , api_token: ''
+};
View
@@ -0,0 +1,13 @@
+var Posterous = require('../index');
+var config = require('./config');
+
+var posterous = new Posterous(config.user, config.pass, config.api_token);
+
+console.log('Fetching user details...');
+posterous.get('Sites', {site_id: 'tonyto85'}, function(err, result) {
+ console.error(!err, 'An error occurred: ' + err);
+
+ console.log(result, 'Did not retrieve site information');
+
+ console.log(result);
+});
View
@@ -0,0 +1,13 @@
+var Posterous = require('../index');
+var config = require('./config');
+
+ var posterous = new Posterous(config.user, config.pass, config.api_token);
+
+ console.log('Fetching user details...');
+ posterous.get('User', null, function(err, result) {
+ console.error(!err, 'An error occurred: ' + err);
+
+ console.log(result, 'Did not retrieve user information');
+
+ console.log(result);
+ });
View
@@ -6,9 +6,9 @@ var HOST = 'posterous.com';
var PATH = '/api/2/';
-var Posterous = function(user, pass) {
+var Posterous = function(user, pass, api_token) {
this._auth = 'Basic ' + new Buffer(user + ':' + pass).toString('base64');
- this._token = null;
+ this._token = api_token;
};
@@ -44,6 +44,7 @@ Posterous.prototype.request = function(method, api, args, callback) {
headers: headers
};
+ console.log('uri path: ' + reqOptions.path);
//Make request to Posterous API
var req = http.request(reqOptions, function apiRequest(res) {
//Gather response
@@ -81,6 +82,7 @@ Posterous.prototype.request = function(method, api, args, callback) {
};
Posterous.prototype.makeRequest = function(method, args) {
+console.log('in makeRequest trying');
if (args.length < 3) {
return console.error('[Posterous] You must pass arguments to the method.');
}
@@ -126,6 +128,7 @@ Posterous.prototype.makeRequest = function(method, args) {
Posterous.prototype.get = function() {
+ console.log('about to get');
this.makeRequest('GET', arguments);
};
@@ -141,22 +144,4 @@ Posterous.prototype.del = Posterous.prototype.delete = function() {
this.makeRequest('DELETE', arguments);
};
-
-//Get api token
-Posterous.prototype.auth = function(callback) {
- var t = this;
-
- this.request('GET', 'auth/token', null, function(err, result) {
- if (err) {
- return callback(err);
- }
-
- //Save api token
- t._token = result.api_token;
-
- callback(null, result.api_token);
- });
-};
-
-
module.exports = Posterous;

0 comments on commit fa279b2

Please sign in to comment.