The Facebook Stream module aims to provide an easily customisable block for displaying posts from a Facebook page. It uses Facebook's Graph API to retrieve posts from the timeline of a particular Facebook page, and then filters the returned posts based on the module's settings, before rendering the final block with a template file.

The current settings available to customise the stream are:

  • The number of posts to display in the stream
  • The types of posts to display in the stream
  • Limiting posts to those created by the Facebook page itself
  • The maximum number of requests to make to Facebook in order to retrieve the specified number of posts that meet your selection criteria
  • The length of time to cache the stream data

The basic workflow for the module when the block is displayed is:

  1. The module returns a cached version of the stream if there is one available.
  2. If there is no cached stream, the module makes a request to Facebook for an access token using the Facebook application ID and secret from the module's settings.
  3. The module uses the returned access token to make a Graph API request for the feed of the Facebook page with the page ID from the module's settings.
  4. The module loops through the posts returned by Facebook, processing posts that meet post type and poster configurations and adding them to a list of posts to display. When the set number of posts to display has been reached, the stream is cached and sent to the theme template for rendering.
  5. If the module finishes processing the posts returned by Facebook without reaching the number of posts to display, then it makes another request to Facebook for more posts, and continues to process the new posts.
  6. The module will continue to make new requests to Facebook until it either reaches the set number of posts to display, or it reaches the maximum number of requests to make to Facebook. The maximum number of requests defaults to 1, so by default the module will only make 2 requests to Facebook: one for the access token, and one for the posts.

Similar Modules:

Facebook Pull also provides a block to display Facebook posts, but it does not provide options for filtering the posts that are displayed. Also, while Facebook Pull has a limit for the number of posts to display, Facebook Stream can be configured to make multiple requests in order to display the number of posts set on the settings page.

My Background:

I have had a part time job developing Drupal websites for almost 2 years, including working on modules and themes.

Links:

Project page: http://drupal.org/sandbox/ben.denham/1959688

Git repository: git clone --branch 7.x-1.x http://git.drupal.org/sandbox/ben.denham/1959688.git facebook_stream

Comments

PA robot’s picture

We are currently quite busy with all the project applications and we prefer projects with a review bonus. Please help reviewing and we will take a look at your project right away :-)

Also, you should get your friends, colleagues or other community members involved to review this application. Let them go through the review checklist and post a comment that sets this issue to "needs work" (they found some problems with the project) or "reviewed & tested by the community" (they found no major flaws).

I'm a robot and this is an automated message from Project Applications Scraper.

dimitrov.adrian’s picture

Status: Needs review » Needs work
  // We suppress the output of the request so that we do not log
  // the Facebook application's ID and secret.
 $response = @file_get_contents($request);

Try using drupal_http_request() instead of file_get_contents().

ben.denham’s picture

Status: Needs work » Needs review

Thanks dimitrov.adrian!

I've updated fb_stream_make_request() to use drupal_http_request() instead of file_get_contents().

Kind regards,
Ben

jongagne’s picture

Recommendations:

  • After configuring the module with an invalid Facebook page ID and hitting save we get two errors, both of which you can see below.
    Notice: Undefined property: stdClass::$paging in fb_stream_get_stream() (line 205 of /var/www/modules/facebook_stream/fb_stream.module).
    
    Notice: Trying to get property of non-object in fb_stream_get_stream() (line 205 of /var/www/modules/facebook_stream/fb_stream.module).
    

    If possible provide some kind of error message similar to "Please enter a valid Facebook page ID".

  • When configuring the module you are able to enter a number of maximum posts to be displayed. After entering large numbers (i.e 9001) there appears to be a maximum limit of 15 items per stream (I might be mistaken as I have not reviewed the code itself). However if there is a 15 item limit consider modifying the description to reflect it.

Suggested Future Improvements:

  • It might be a good idea to modify the README.txt to include configuration instructions as not everyone knows where to find a Facebook page ID.
  • Go into more detail when writing field descriptions because the description for the option to "Restrict stream to posts published by the page":

    If this is selected, then only posts that were published by the page itself will be displayed in the stream.

    The sentence left a lot of room for misinterpretation (i.e it will only allow posts published on the Facebook page appear on the screen?). It was my understanding that was the purpose of the module unless you are able to use multiple Facebook page ID's in the same block at a time.

ben.denham’s picture

Hi jongagne, thanks for all of the feedback!

Here is what I've done to address those issues:

  1. You should no longer receive the undefined property error message if you cannot retrieve posts for a given Facebook page ID, but it is up to the module configurer to make sure that their page ID actually corresponds to a page on Facebook.
  2. There is no absolute limit for the number of posts that can be displayed; the apparent limit of 15 posts is the number of posts that meet your validation criteria that have been retrieved from Facebook in the number of requests set in 'Maximum Requests'. If you increase the 'Maximum Requests' setting, then more requests may be made to Facebook in order to find more posts meeting your validation criteria. I have updated the README.txt to suggest increasing 'Maximum Requests' if fewer posts are displaying than you expect.
  3. I have also added a new section to README.txt that provides instructions for post-installation configuration, including how to find your Facebook page ID.
  4. The "Restrict stream to posts published by the page" is intended for excluding posts that other users have posted to your page, and therefore only displaying posts that were actually created by the page itself. I have updated the field value and description to clarify this.

Thanks again for the review!

Kind regards,
Ben

afi_amouzou’s picture

Status: Needs review » Needs work

I installed the module and fill the form but I get this error: Fatal error: Call to undefined function element_validate_nonnegative_number() in fb_stream.admin.inc on line 112

You are calling this function but it is not defined.

ben.denham’s picture

Status: Needs work » Needs review

Hi afi_amouzou, thanks for pointing that out.

I had added a new field to the configuration form and had misspelt the validation function name.
This issue has now been resolved.

Thanks again,
Ben

kscheirer’s picture

Status: Needs review » Reviewed & tested by the community

Code looks good. Consider detailing the difference with Facebook Pull more clearly than what's on the current project page. The original post here is more informative:

Facebook Pull also provides a block to display Facebook posts, but it does not provide options for filtering the posts that are displayed. Also, while Facebook Pull has a limit for the number of posts to display, Facebook Stream can be configured to make multiple requests in order to display the number of posts set on the settings page.

The code looks good.

----
Top Shelf Modules - Enterprise modules from the community for the community.

ben.denham’s picture

Thank you very much for the review kscheirer.

I have replaced the original "Similar Modules" section on the project page and readme.txt with the more detailed paragraph from this thread as you suggested.

Thanks again,
Ben

abhijeetkalsi’s picture

Hi ben.denham

Good efforts. But have one question that one of my module named 'Facebook Wall' is already exists providing the FB wall posts with better theming & user comments.

Is your module do anything new to it ?

kscheirer’s picture

Status: Reviewed & tested by the community » Needs work

Based on #10, need more information about that.

ben.denham’s picture

Status: Needs work » Needs review

Hi there AbhijeetKalsi,

After examining your module, I would say that the features that distinguish my module from yours are:

  • As with Facebook Pull, while your module allows the user to set a limit for the number of posts to display, my module can be configured to make multiple requests in order to display a specific number of posts. So it has more of a "target" number of posts than a limit.
  • My module does not require the user to enter an access token on the settings page, but generates one when it needs to make a request.

I was initially confused as to why I didn't see your module when I was searching for similar modules before making this post, and then I realised that your module was posted on April 19, while mine was posted on April 3.

Kind regards,
Ben

abhijeetkalsi’s picture

Hi Ben denham,

1) I had developed my module in month of march but it take time to test & review its working, Thats why I deploy in april.

2) Since Access token it provided by facebook expires in one hour and I had convert that token in 60 day which is very necessary and not applied in your module.

3) Also, i had not fixed the no of wall post limit. There is a Get Older post button on wall post page that display the next older post.

I am not against you module. It my advice to add some extra features that helps your module to contribute.

kscheirer’s picture

If the differences between these modules are not too fundamental for patching the existing one, we would love to see you joining forces and concentrate all power on enhancing one module.

kscheirer’s picture

Status: Needs review » Postponed (maintainer needs more info)

Please set back to "needs review" if you are unable to work together for any reason or feel that the modules are significantly different.

PA robot’s picture

Status: Postponed (maintainer needs more info) » Closed (won't fix)

Closing due to lack of activity. Feel free to reopen if you are still working on this application.

I'm a robot and this is an automated message from Project Applications Scraper.