Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added more implements for posts.

  • Loading branch information...
commit 637a8057fd6a21877a136dcf6ae4d07302129d1c 1 parent 5263b40
@llun authored
Showing with 25 additions and 9 deletions.
  1. +18 −2 services/facebook.js
  2. +7 −7 spec/remote/test_facebook.js
View
20 services/facebook.js
@@ -86,8 +86,24 @@ Facebook.prototype.parameters = function (input) {
* @param cb
*/
Facebook.prototype.me = function (token, cb) {
- var parameters = this.parameters(arguments);
- this.oauth.get('https://graph.facebook.com/me', parameters.token, parameters.cb);
+ var options = this.parameters(arguments);
+ this.oauth.get('https://graph.facebook.com/me', options.token, options.cb);
+}
+
+/**
+ * Fetch posts from facebook
+ *
+ * @param token
+ * @param user
+ * @param page
+ * @param since, timestamp for query
+ * @param cb
+ */
+Facebook.prototype.posts = function (token, user, page, since, cb) {
+ var options = this.parameters(arguments);
+ this.oauth.get('https://graph.facebook.com/' + user + '/posts', options.token, function (err, raw) {
+ options.cb(err, raw.data);
+ });
}
/**
View
14 spec/remote/test_facebook.js
@@ -16,7 +16,7 @@ describe('facebook', function () {
// Because Facebook API may return slower than expect, increase timeout is a better option.
this.timeout(20000);
- var testerUserID = '100005204405638';
+ var testerUserID = '100005588648149';
var facebook = null;
var applicationToken = null;
@@ -72,26 +72,26 @@ describe('facebook', function () {
describe ('#posts', function () {
it ('should return first page posts since the beginning of time', function () {
- return q.nfcall(facebook.posts)
+ return q.nfcall(facebook.posts.bind(facebook), userToken, 'me')
.then(function (posts) {
-
+ posts.should.have.length(5);
});
});
- it ('should return second page posts since the beginning of time', function () {
+ it ('should return posts since specific time', function () {
// Have to test which is second page numeric, 1 or 2
- return q.nfcall(facebook.posts, 1)
+ return q.nfcall(facebook.posts.bind(facebook), userToken, 'me', '2013-04-01T14:59:07 0000')
.then(function (posts) {
});
});
- it ('should return posts since the specific time', function () {
+ it ('should return posts since specific time second page', function () {
// timestamp will changed later, have to manipulate data in facebook first?
var timestamp = new Date().getTime();
- return q.nfcall(facebook.posts, 0, timestamp)
+ return q.nfcall(facebook.posts.bind(facebook), userToken, 'me', '2013-04-01T14:59:07 0000', 1)
.then(function (posts) {
});
Please sign in to comment.
Something went wrong with that request. Please try again.