Skip to content

A small Javascript and PHP component to display a Facebook page feed on a website.

Notifications You must be signed in to change notification settings

lemonarc/facebook-graph-feed

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

facebook-graph-feed

A small Javascript and PHP component to display a Facebook page feed on a website.

Requirements

Requires jQuery for now (will try and get rid of this dependency soon).

Setup

You need to have created a Facebook app to get an app ID and secret: https://developers.facebook.com/apps/

Copy .env.example to a file called .env and update your environment variables as required:

# Your app ID from your facebook app
APP_ID=1111111111111

# Your app secret from your facebook app
APP_SECRET=abcdef1234567890

# The page you want to display the feed for (this unique ID is in the URL of the page)
PAGE_NAME=MyFacebookPage

# The max number of recent posts to display (defaults to 12)
POST_LIMIT=12

Place this .env file one folder above your document root, the PHP script will look for it there (you don't want people to be able to navigate to this file in their browser and see your app secret!).

Usage

Place all the contents of this project apart from your .env file in a folder on your website, and include on the page you want to use as so:

    <script type="text/javascript">
        facebookFeedConfig = {
          scriptDirectory: '/facebook',
          showMessage: false,
          messageMaxCharacters: 100,
          defaultImage: 'http://lorempixel.com/400/200',
          showDate: false,
          linkText: 'See more...'
        }
    </script>
    <script src="/facebook/index.js" type="text/javascript"></script>
    

Config Options:

Option Default Description
scriptDirectory REQUIRED: The public location of this folder. In the above example it is '/facebook'
showMessage false Whether or not to show the message field
messageMaxCharacters The max characters to show of the message (message will be truncated)
defaultImage Image to display when there is no image field
showDate false Whether or not to show the date
linkText Link text (overwrites the name of the post)

About

A small Javascript and PHP component to display a Facebook page feed on a website.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published