Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Revert "* added secure url"
This reverts commit 57c21b5.
  • Loading branch information
DracoBlue committed Dec 29, 2010
1 parent 57c21b5 commit 25c55eb
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 9 deletions.
10 changes: 9 additions & 1 deletion README.md
@@ -1,7 +1,7 @@
node-facebook-client README
===========================

Version: 1.0.0
Version: 1.0.1

Official Site: <http://dracoblue.net/>

Expand Down Expand Up @@ -141,6 +141,14 @@ FacebookSession.

Calculates the signature for a given set of parameters and the api_secret.

Changelog
---------

- 1.0.1 (2010/12/29)
- added secure url for access_token
- 1.0.0 (2010/10/05)
- Initial release

License
--------

Expand Down
25 changes: 18 additions & 7 deletions lib/facebook-client/FacebookClient.js
Expand Up @@ -14,9 +14,9 @@ var querystring = require("querystring");
var FacebookSession = require("./FacebookSession").FacebookSession;
var FacebookToolkit = require("./FacebookToolkit");

function doRawJsonRequest(host, port, path) {
function doRawJsonRequest(host, port, path, secure) {
return function(cb) {
var connection = http.createClient(port, host);
var connection = http.createClient(port, host, secure);
var request = connection.request('GET', path, {'host': host});

request.addListener('response', function(response){
Expand All @@ -38,9 +38,9 @@ function doRawJsonRequest(host, port, path) {
};


function doRawQueryRequest(host, port, path) {
function doRawQueryRequest(host, port, path, secure) {
return function(cb) {
var connection = http.createClient(port, host);
var connection = http.createClient(port, host, secure);
var request = connection.request('GET', path, {'host': host});

request.addListener('response', function(response){
Expand Down Expand Up @@ -68,6 +68,8 @@ var FacebookClient = function(api_key, api_secret, options) {

this.options.facebook_graph_server_host = this.options.facebook_graph_server_host || 'graph.facebook.com';
this.options.facebook_graph_server_port = this.options.facebook_graph_server_port || '80';
this.options.facebook_graph_server_port = this.options.facebook_graph_secure_server_port || '443';
this.options.facebook_graph_server_host = this.options.facebook_graph_secure_server_host || 'graph.facebook.com';

this.options.facebook_server_host = this.options.facebook_server_host || 'api.facebook.com';
this.options.facebook_server_port = this.options.facebook_server_port || '80';
Expand Down Expand Up @@ -116,7 +118,16 @@ var FacebookClient = function(api_key, api_secret, options) {
};

this.graphCall = function(path, params) {
return doRawJsonRequest(self.options.facebook_graph_server_host, self.options.facebook_graph_server_port, path + '?' + querystring.stringify(params));
if (params.access_token) {
/*
* We have to do a secure request, because the access_token is given. This is HTTPS.
*/
return doRawJsonRequest(self.options.facebook_graph_secure_server_host, self.options.facebook_graph_secure_server_port, path + '?' + querystring.stringify(params), true);
}
/*
* No access token given, let's take HTTP because it's faster.
*/
return doRawJsonRequest(self.options.facebook_graph_server_host, self.options.facebook_graph_server_port, path + '?' + querystring.stringify(params), false);
};

this.getAccessToken = function(params) {
Expand All @@ -130,7 +141,7 @@ var FacebookClient = function(api_key, api_secret, options) {
}

return function(cb) {
doRawQueryRequest(self.options.facebook_graph_server_host, self.options.facebook_graph_server_port, "/oauth/access_token" + '?' + querystring.stringify(access_params))(function(response) {
doRawQueryRequest(self.options.facebook_graph_secure_server_host, self.options.facebook_graph_secure_server_port, "/oauth/access_token" + '?' + querystring.stringify(access_params), true)(function(response) {
cb(response.access_token, response.expires);
});
};
Expand Down Expand Up @@ -166,4 +177,4 @@ FacebookClient.prototype.getSessionByAccessToken = function(access_token) {
// };
//};

exports.FacebookClient = FacebookClient;
exports.FacebookClient = FacebookClient;
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name" : "facebook-client",
"version": "1.0.0",
"version": "1.0.1",

"engines": { "node": ">= 0.2.0" },

Expand Down

0 comments on commit 25c55eb

Please sign in to comment.