Skip to content

facebook

David Spreekmeester edited this page Dec 2, 2014 · 1 revision

Facebook

Setting up

App ID: mandatory for any of these plugins In order to use any of the Facebook social plugins mentioned below, you'll have to add the following somewhere at the bottom of the layout:

<?php echo $this->social()->facebookInit() ?>

Then uncomment the following line in application/configs/application.ini:

auth.adapters.facebook.appId = ""

Next, fill out the value with the appId you get from your friendly system administrator, after you ask him for a Facebook App. When you're at it, fill out another value you'll get it with the appId:

auth.adapters.facebook.secret = ""

App Admins: mandatory for setting Open Graph tags

You probably need to set out some Open Graph data for your page as well, to describe it to Facebook. If so, you'll need to 'prove' that you're the owner of a Facebook page that's linked to the website, by providing the Facebook user IDs of the people administrating the Facebook page. This can be a single number, or a comma-separated list, also in application/configs/application.ini:

auth.adapters.facebook.admins = "591114033,1598442524"

To find out which admins there are for the Facebook page, you'll have to ask for their Facebook user page url, because there is no legit way to find out through the site. To find out the Facebook user ID from a Facebook user name (where the user page url ends in), poll OpenGraph:

http://graph.facebook.com/fritsvanderplof

Replace fritsvanderplof with the user name. The OpenGraph API tolerates some fuzziness here. This call will give you the basic public information on the given user, including user ID.

Debugging OpenGraph

If you run into any case of resistance, it helps to debug your Facebook OpenGraph settings with the FB debugger

Rendering a Facebook like button

From a view or a partial, call the required method of the social helper:

<?php echo $this->social()->facebookLikeButton() ?>

If the targeted page is not the current url, then specify it:

<?php echo $this->social()->facebookLikeButton(array(
	'href' => $this->fullUrl('/bumsocks')
)) ?>

You can specify other parameters according to Facebook's XFBML standard for like buttons in the same fashion.

If you want the like button to point to an accompanying Facebook page, set the second parameter to true:

<?php echo $this->social()->facebookLikeButton(array(), true) ?>

A common bug is a cut-off comment-box when you click "Like". This happens when the Facebook like button is too small. (450 pixels is recommended) Fix it like this:

.fb_iframe_widget span { width: 450px !important; }

Rendering a Facebook recommend button From a view or a partial, call the required method of the social helper:

<?php echo $this->social()->facebookRecommendButton() ?>

Rendering a Facebook facepile

From a view or a partial, call the required method of the social helper:

<?php echo $this->social()->facebookFacepile() ?>

If you want the facepile to point to an accompanying Facebook page, set the second parameter to true:

<?php echo $this->social()->facebookFacepile(array(), true) ?>

You can use the first array parameter to override default Facebook settings, as you would do when directly setting an FBXML tag.

Rendering Facebook comments

From a view or a partial, call the required method of the social helper:

<?php echo $this->social()->facebookComments() ?>
Clone this wiki locally