Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

adding npm package info

  • Loading branch information...
commit 53366c8d41b809044935665545e635905f3cae4d 1 parent 17f8d57
Cristiano Oliveira authored
2  .gitignore
View
@@ -0,0 +1,2 @@
+*.swp
+dev_only/*
0  README → README.md
View
File renamed without changes
118 blah
View
@@ -1,118 +0,0 @@
-{ topic: function () {
- fs.stat('~/FILE', this.callback);
- },
- 'can be accessed': function (err, stat) {
- assert.isNull (err); // We have no error
- assert.isObject (stat); // We have a stat object
- },
- 'is not empty': function (err, stat) {
- assert.isNotZero (stat.size); // The file size is > 0
- }
-}
-
-
-
-
-
-
-
-
-
-{ topic: function () {
- fs.stat('~/FILE', this.callback);
- },
- 'after a successful `fs.stat`': {
- topic: function (accstat) {
- fs.open('~/FILE', "r", stat.mode, this.callback);
- },
- 'after a successful `fs.open`': {
- topic: function (fd, stat) {
- fs.read(fd, stat.size, 0, "utf8", this.callback);
- },
- 'we can `fs.read` to get the file contents': function (data) {
- assert.isString (data);
- }
- }
- }
-}
-
-
-
-
-var https = require('https');
-
-var options = {
- host: 'encrypted.google.com',
- port: 443,
- path: '/',
- method: 'GET'
-};
-
-var req = https.request(options, function(res) {
- console.log("statusCode: ", res.statusCode);
- console.log("headers: ", res.headers);
-
- res.on('data', function(d) {
- process.stdout.write(d);
- });
-});
-req.end();
-
-req.on('error', function(e) {
- console.error(e);
-});
-
-// =======================================
-function PostCode(codestring) {
- // Build the post string from an object
- var post_data = querystring.stringify({
- 'compilation_level' : 'ADVANCED_OPTIMIZATIONS',
- 'output_format': 'json',
- 'output_info': 'compiled_code',
- 'warning_level' : 'QUIET',
- 'js_code' : codestring
- });
-
- var post_options = {
- host: 'closure-compiler.appspot.com',
- port: '80',
- path: '/compile',
- method: 'POST',
- headers: {
- 'Content-Type': 'application/x-www-form-urlencoded',
- 'Content-Length': post_data.length
- }
- };
-
- var post_req = http.request(post_options, function(res) {
- res.setEncoding('utf-8');
- res.on('data', function (chunk) {
- console.log('Response: ' + chunk);
- });
- });
-
- post_req.write(post_data);
- post_req.end();
-}
-
-// ====================================================
-curl \
- –F 'access_token=…' \
- -F 'batch=[ \
- {"method": "GET", "relative_url": "me"}, \
- {"method": "GET", "relative_url": "me/friends?limit=50"} \
- ]'\
- https://graph.facebook.com
-
-
-
-
-
-
-
-
-
-
-
-
-
1  index.js
View
@@ -0,0 +1 @@
+module.exports = require('./lib/graph');
9 lib-cov/config.js
View
@@ -1,9 +0,0 @@
-/* automatically generated by JSCoverage - do not edit */
-if (typeof _$jscoverage === 'undefined') _$jscoverage = {};
-if (! _$jscoverage['config.js']) {
- _$jscoverage['config.js'] = [];
- _$jscoverage['config.js'][1] = 0;
-}
-_$jscoverage['config.js'][1]++;
-module.exports = {facebook: {appId: "193097990710217", appSecret: "1242bb60970bff12916baca437cb0492", scope: "email, user_about_me, user_birthday, user_location, publish_stream, friends_location", callback: "http://localhost:3000/auth/facebook"}};
-_$jscoverage['config.js'].source = ["module.exports = {"," facebook: {"," appId: '193097990710217',"," appSecret: '1242bb60970bff12916baca437cb0492',"," scope: 'email, user_about_me, user_birthday, user_location, publish_stream, friends_location',"," callback: 'http://localhost:3000/auth/facebook'"," }","};"];
196 lib-cov/graph.js
View
@@ -1,196 +0,0 @@
-/* automatically generated by JSCoverage - do not edit */
-if (typeof _$jscoverage === 'undefined') _$jscoverage = {};
-if (! _$jscoverage['graph.js']) {
- _$jscoverage['graph.js'] = [];
- _$jscoverage['graph.js'][5] = 0;
- _$jscoverage['graph.js'][15] = 0;
- _$jscoverage['graph.js'][21] = 0;
- _$jscoverage['graph.js'][28] = 0;
- _$jscoverage['graph.js'][37] = 0;
- _$jscoverage['graph.js'][38] = 0;
- _$jscoverage['graph.js'][40] = 0;
- _$jscoverage['graph.js'][41] = 0;
- _$jscoverage['graph.js'][42] = 0;
- _$jscoverage['graph.js'][43] = 0;
- _$jscoverage['graph.js'][44] = 0;
- _$jscoverage['graph.js'][46] = 0;
- _$jscoverage['graph.js'][49] = 0;
- _$jscoverage['graph.js'][55] = 0;
- _$jscoverage['graph.js'][57] = 0;
- _$jscoverage['graph.js'][60] = 0;
- _$jscoverage['graph.js'][61] = 0;
- _$jscoverage['graph.js'][62] = 0;
- _$jscoverage['graph.js'][65] = 0;
- _$jscoverage['graph.js'][76] = 0;
- _$jscoverage['graph.js'][77] = 0;
- _$jscoverage['graph.js'][84] = 0;
- _$jscoverage['graph.js'][85] = 0;
- _$jscoverage['graph.js'][88] = 0;
- _$jscoverage['graph.js'][89] = 0;
- _$jscoverage['graph.js'][90] = 0;
- _$jscoverage['graph.js'][92] = 0;
- _$jscoverage['graph.js'][99] = 0;
- _$jscoverage['graph.js'][107] = 0;
- _$jscoverage['graph.js'][108] = 0;
- _$jscoverage['graph.js'][110] = 0;
- _$jscoverage['graph.js'][112] = 0;
- _$jscoverage['graph.js'][113] = 0;
- _$jscoverage['graph.js'][116] = 0;
- _$jscoverage['graph.js'][117] = 0;
- _$jscoverage['graph.js'][118] = 0;
- _$jscoverage['graph.js'][123] = 0;
- _$jscoverage['graph.js'][128] = 0;
- _$jscoverage['graph.js'][141] = 0;
- _$jscoverage['graph.js'][142] = 0;
- _$jscoverage['graph.js'][143] = 0;
- _$jscoverage['graph.js'][148] = 0;
- _$jscoverage['graph.js'][155] = 0;
- _$jscoverage['graph.js'][156] = 0;
- _$jscoverage['graph.js'][157] = 0;
- _$jscoverage['graph.js'][158] = 0;
- _$jscoverage['graph.js'][165] = 0;
- _$jscoverage['graph.js'][166] = 0;
- _$jscoverage['graph.js'][167] = 0;
- _$jscoverage['graph.js'][170] = 0;
- _$jscoverage['graph.js'][178] = 0;
- _$jscoverage['graph.js'][179] = 0;
- _$jscoverage['graph.js'][186] = 0;
- _$jscoverage['graph.js'][187] = 0;
-}
-_$jscoverage['graph.js'][5]++;
-var https = require("https"), querystring = require("querystring"), util = require("util"), EventEmitter = require("events").EventEmitter, noop = (function () {
-});
-_$jscoverage['graph.js'][15]++;
-var accessToken = null;
-_$jscoverage['graph.js'][21]++;
-exports.version = "0.1.0";
-_$jscoverage['graph.js'][28]++;
-exports.graphUrl = "graph.facebook.com";
-_$jscoverage['graph.js'][37]++;
-function Graph(method, url, fn) {
- _$jscoverage['graph.js'][38]++;
- EventEmitter.call(this);
- _$jscoverage['graph.js'][40]++;
- url = this.cleanUrl(url);
- _$jscoverage['graph.js'][41]++;
- this.callback = fn || noop;
- _$jscoverage['graph.js'][42]++;
- this.body = "";
- _$jscoverage['graph.js'][43]++;
- this.options = {host: exports.graphUrl, path: url};
- _$jscoverage['graph.js'][44]++;
- this[method.toLowerCase()]();
- _$jscoverage['graph.js'][46]++;
- return this;
-}
-_$jscoverage['graph.js'][49]++;
-util.inherits(Graph, EventEmitter);
-_$jscoverage['graph.js'][55]++;
-Graph.prototype.cleanUrl = (function (url) {
- _$jscoverage['graph.js'][57]++;
- if (! url.match(/^\//)) {
- _$jscoverage['graph.js'][57]++;
- url = "/" + url;
- }
- _$jscoverage['graph.js'][60]++;
- if (accessToken) {
- _$jscoverage['graph.js'][61]++;
- url += url.indexOf("?") !== -1? "&": "?";
- _$jscoverage['graph.js'][62]++;
- url += querystring.stringify(accessToken);
- }
- _$jscoverage['graph.js'][65]++;
- return url;
-});
-_$jscoverage['graph.js'][76]++;
-Graph.prototype.write = (function (data) {
- _$jscoverage['graph.js'][77]++;
- this.body += data;
-});
-_$jscoverage['graph.js'][84]++;
-Graph.prototype.end = (function (imageData) {
- _$jscoverage['graph.js'][85]++;
- var json = imageData || null, err = null;
- _$jscoverage['graph.js'][88]++;
- if (! json) {
- _$jscoverage['graph.js'][89]++;
- try {
- _$jscoverage['graph.js'][90]++;
- json = JSON.parse(this.body);
- }
- catch (e) {
- _$jscoverage['graph.js'][92]++;
- err = {error: "Error parsing json", excetpion: e};
- }
- }
- _$jscoverage['graph.js'][99]++;
- this.callback(err, json);
-});
-_$jscoverage['graph.js'][107]++;
-Graph.prototype.get = (function () {
- _$jscoverage['graph.js'][108]++;
- var self = this;
- _$jscoverage['graph.js'][110]++;
- https.get(this.options, (function (res) {
- _$jscoverage['graph.js'][112]++;
- res.on("data", (function (data) {
- _$jscoverage['graph.js'][113]++;
- self.write(data);
-}));
- _$jscoverage['graph.js'][116]++;
- res.on("end", (function () {
- _$jscoverage['graph.js'][117]++;
- if (res.headers["content-type"].indexOf("image") !== -1) {
- _$jscoverage['graph.js'][118]++;
- self.end({image: true, location: res.headers.location});
- }
- else {
- _$jscoverage['graph.js'][123]++;
- self.end();
- }
-}));
-})).on("error", (function (err) {
- _$jscoverage['graph.js'][128]++;
- self.callback({error: "Error processing https request", exception: err}, null);
-}));
-});
-_$jscoverage['graph.js'][141]++;
-exports.get = (function (url, fn) {
- _$jscoverage['graph.js'][142]++;
- if (typeof url !== "string") {
- _$jscoverage['graph.js'][143]++;
- return fn({error: "Graph api url must be a string"}, null);
- }
- _$jscoverage['graph.js'][148]++;
- return new Graph("GET", url, fn);
-});
-_$jscoverage['graph.js'][155]++;
-exports.search = (function (options, fn) {
- _$jscoverage['graph.js'][156]++;
- options = options || {};
- _$jscoverage['graph.js'][157]++;
- var url = "/search?" + querystring.stringify(options);
- _$jscoverage['graph.js'][158]++;
- return new Graph("GET", url, fn);
-});
-_$jscoverage['graph.js'][165]++;
-exports.authorizeUrl = (function (opts) {
- _$jscoverage['graph.js'][166]++;
- if (! opts) {
- _$jscoverage['graph.js'][167]++;
- throw new Error("AuthorizeUrl Must have a redirectUri");
- }
- _$jscoverage['graph.js'][170]++;
- return "https://www.facebook.com/dialog/oauth?" + querystring.stringify(opts);
-});
-_$jscoverage['graph.js'][178]++;
-exports.setAccessToken = (function (token) {
- _$jscoverage['graph.js'][179]++;
- accessToken = {access_token: token};
-});
-_$jscoverage['graph.js'][186]++;
-exports.getAccessToken = (function () {
- _$jscoverage['graph.js'][187]++;
- return accessToken.access_token;
-});
-_$jscoverage['graph.js'].source = ["/**"," * Module Dependencies"," */","","var https = require('https')"," , querystring = require('querystring')"," , util = require('util')"," , EventEmitter = require('events').EventEmitter"," , noop = function(){};","","/**"," * @private"," */","","var accessToken = null;","","/**"," * Library version"," */","","exports.version = '0.1.0';","","","/**"," * Graph api url"," */","","exports.graphUrl = 'graph.facebook.com';","","","/**"," * Graph Stream"," *"," * @param {String} method"," * @param {String} url"," */","function Graph(method, url, fn) {"," EventEmitter.call(this);",""," url = this.cleanUrl(url);"," this.callback = fn || noop;"," this.body = '';"," this.options = { host: exports.graphUrl , path: url };"," this[method.toLowerCase()]();",""," return this;","}","","util.inherits(Graph, EventEmitter);","","/**"," *"," */","","Graph.prototype.cleanUrl = function(url) {"," // add leading slash"," if (!url.match(/^\\//)) { url = '/' + url; }",""," // add access token to url"," if (accessToken) {"," url += url.indexOf('?') !== -1 ? '&' : '?';"," url += querystring.stringify(accessToken);"," }",""," return url;","","};","","","","/**"," *"," * @param {Mixed} data"," */","","Graph.prototype.write = function (data) {"," this.body += data;","};","","/**"," * @param {object} imageData"," */","","Graph.prototype.end = function (imageData) {"," var json = imageData || null"," , err = null;",""," if (!json) {"," try {"," json = JSON.parse(this.body); "," } catch (e) {"," err = {"," error: 'Error parsing json'"," , excetpion: e"," }; "," }"," }",""," this.callback(err, json);","};","","","/**"," *"," */","","Graph.prototype.get = function() {"," var self = this;",""," https.get(this.options, function(res) {",""," res.on('data', function (data) {"," self.write(data);"," });",""," res.on('end', function () {"," if (res.headers['content-type'].indexOf('image') !== -1 ) {"," self.end({"," image: true"," , location: res.headers.location"," });"," } else {"," self.end();"," }"," });",""," }).on('error', function (err) {"," self.callback({"," error: 'Error processing https request'"," , exception: err"," }, null);"," });","","};","","","/**"," *"," */","","exports.get = function(url, fn) {"," if (typeof url !== 'string') {"," return fn({"," error: 'Graph api url must be a string'"," }, null);"," }"," "," return new Graph('GET', url, fn);","};","","/**"," *"," */","","exports.search = function (options, fn) {"," options = options || {};"," var url = '/search?' + querystring.stringify(options);"," return new Graph('GET', url, fn);","};","","/**"," *"," */","","exports.authorizeUrl = function (opts) {"," if (!opts) {"," throw new Error('AuthorizeUrl Must have a redirectUri');"," }",""," return 'https://www.facebook.com/dialog/oauth?' "," + querystring.stringify(opts);","};","","/**"," *"," */","","exports.setAccessToken = function(token) {"," accessToken = { access_token: token };","};","","/**"," *"," */","","exports.getAccessToken = function () {"," return accessToken.access_token;","};","","// /**","// *","// */","// ","// exports.setAccessToken = function(config, code, fn) {","// var callback = fn || exports.noop;","// ","// var oAuth = new OAuth(","// config.appId","// , config.secret","// , 'https://' + exports.graphUrl","// );","// ","// oAuth.getOAuthAccessToken(code, { ","// redirect_uri: config.callback ","// }, callback);","// };"];
13 oldMakefile
View
@@ -1,13 +0,0 @@
-TESTS = $(shell find test/*.test.js)
-
-test:
- @NODE_ENV=test expresso \
- -I lib \
- $(TESTFLAGS) \
- $(TESTS)
-
-
-test-cov
- @TESTFLAGS=--cov $(MAKE) test
-
-.PHONY: test
28 package.json
View
@@ -1,11 +1,23 @@
{
- "name": "application-name"
- , "version": "0.0.1"
- , "private": true
- , "dependencies": {
- "express": "2.4.3"
- , "jade": ">= 0.0.1"
- , "everyauth": ">= 0.2.17"
- , "oauth": ">=0.9.3"
+ "name": "fbgraph",
+ "version": "0.0.1",
+ "description": "a cleaner client to access the facebook graph api",
+ "keywords": [
+ "facebook",
+ "api",
+ "graph"
+ ],
+ "author": "Cristiano Oliveira <ocean.cris@gmail.com>",
+ "devDependencies": {
+ "vows": ">= 0.5.11"
+ },
+ "main": "index",
+ "engines": {
+ "node": "0.4.x"
+ },
+ "dependencies": {},
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/criso/graphapi.git"
}
}
14 repl
View
@@ -1,14 +0,0 @@
-var graph = require('./lib/graph') , FBConfig = require('./lib/config').facebook;
-
-
-var testUserUrl = '/' + FBConfig.appId + '/accounts/test-users?' +
-'installed=true' +
-'&name=Ricky Bobby' +
-'&permissions=' + FBConfig.scope +
-'&method=post' +
-'&access_token=' + FBConfig.appId + '|' + FBConfig.appSecret;
-
-graph.get(encodeURI(testUserUrl), function(err, res) {
- console.log("err: => ", err);
- console.log("res: => ", res);
-});
23 todo.markdown
View
@@ -1,23 +0,0 @@
-###########
-# Next
-###########
-
-- npm package setup
-
-- Get Access Token (same way as js sdk)
- - if user has previously connected, we should be able to
- get the access token
-
-- Oauth won't be handled by the api (leave that for oauth package)
-
-
-
-
-# ON code
-Mimic this:
-- https://developers.facebook.com/docs/reference/javascript/
-
-- assume we have a valid access token and go from there for now
- - set the access token using everyauth
- - use setAccessToken()
- - on request if accessToken isn't set, we should get one
Please sign in to comment.
Something went wrong with that request. Please try again.