MediaWiki extensions manual
OOjs UI icon advanced.svg
Release status: beta
Implementation User interface
Description An extension to import publicly available Facebook material into Mediawiki user pages
Author(s) Patrick McCann
Latest version 0.2 (2012-11-05)
MediaWiki 1.19 (untested on older versions)
License GPL
Download https://github.com/openplanets/SPRUCE/tree/master/fb-mw-import
Translate the FacebookImport extension if it is available at translatewiki.net
Check usage and version matrix.



A MediaWiki extension to facilitate the transfer of information and resources from Facebook into a wiki. It does this in two ways.

  1. When users log in using Facebook (via the Facebook Open Graph Extension) they are presented with a form populated with information from their Facebook profile, submission of which populates their User Page with that information.
  2. A Special Page is created to which can be submitted the URL of a photograph on Facebook. Upon submission, the photo is imported into the wiki.

Dependencies and RequirementsEdit

  1. Developed using MediaWiki 1.19, untested on other versions.
  2. Requires the Facebook Open Graph Extension.
  3. The MediaWiki API needs to be enabled.
  4. $wgAllowUploads and $wgAllowCopyUploads need to be enabled, and users need to have the upload and upload_by_url permissions, in order to import photos.
  5. $wgEnableAPI and $wgEnableWriteAPI need to be enabled
  6. you will need to provide the values for variables $wgFbAppId and $wgFbSecret from a target Facebook app.


  1. Insert the following into your LocalSettings.php file (but above the PHP end-of-code delimiter,
    require_once( "$IP/extensions/FacebookImport/FacebookImport.php" );


Firstly, ensure the Facebook Open Graph Extension is configured correctly to work with your chosen Facebook application. In order to enable photo imports, you will need to add the following hook to your LocalSettings.php file, as also detailed on the Facebook Open Graph Extension wiki page.

$wgHooks['FacebookPermissions'][] = 'fnFBHook';
function fnFBHook( &$scope ) {
    // Unset a permission
    foreach ( $scope as $i => $perm ) {
        if ( $perm == 'email' ) {
            unset( $scope[$i] );
    // Add the additional Facebook permissions required here
    $scope[] = 'publish_actions';
    return true;

This should allow users to import their own photos (or photos they're tagged in). You will need to add the 'user_photos' permission to the scope array for this. The 'friends_photos' permission is needed to allow users to import friends' photos. These permissions also need to be enabled in your Facebook application.

Configuration options for this extension take the form of two arrays in FacebookImport.php, $wgFbImportOptions and $wgFbConnectionImportOptions. The elements of those arrays are themselves arrays, each with three elements - a boolean value to indicate whether that item should be included in the User Page import form, a string for the label for that input, and a string for the type of input (text or textarea).