Skip to content
Michael Haschke edited this page Jul 12, 2015 · 1 revision

Facebook service class

This service integrates public posts from Facebook pages within your PubwichFork page.

Installation: add your Facebook application

Before you can use the Facebook service class you need to create a new Facebook application because the service class needs a valid access token to request data. It's easy to create it:

  1. Go to https://developers.facebook.com/apps/ and create a new application
  2. Fill out the data:
  1. Save it
  2. Get id and secret from the app dashboard

Copy application id and application secret to configure the Facebook service class.

Configuration values

  • method: FacebookPage is provided and supported for now
  • pagename: the page name from the URL, as in https://www.facebook.com/pagename
  • pageid: the id as in https://www.facebook.com/pages/Name-of-Page/pageid is only necessary if the page name is not available
  • app_id: the id of the application that you have created for your PubwichFork instance
  • *app_secret: the secret key of the application

... and all basic options of services.

Example configuration

$facebook_page = array(
    'Facebook', 'facebook_page', array(
		'method' => 'FacebookPage',
		'pagename' => 'angstbreaker',
		'app_id' => 'YOUR_APP_ID_NUMBER',
		'app_secret' => 'YOUR_APP_SECRET_STRING',
		'total' => 5,
		'title' => 'Facebook',
		'description' => 'Angstbreaker news'
	)
);

Template keys

  • message: the original message text if there is any
  • status: the text with links for @username, #hashtag, URL strings; and replacements for known URLs and shared Links
  • date: date of the post
  • link: permanent URL of the post
  • media_thumbnail_url: URL of thumbnail for the post if there is any
  • media_picture_url: URL of a full picture for the post if there is any
  • type: type of the Facebook post, e.g. link, photo, video, ...

Example template

<li class="facebook-{{{type}}}">
    {{#media_thumbnail_url}}
        <img src="{{{media_thumbnail_url}}}" class="item-media-thumbnail" alt="" height="75" />
    {{/media_thumbnail_url}}
    {{{status}}}
    (<a href="{{{link}}}">{{{date}}}</a>)
</li>